Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
I put this at the end of my class files so that running the file directly runs the test for the file.
class Someclass
...
end
########## inline test running
if __FILE__==$PROGRAM_NAME
require_relative '../path_to_test.rb'
end
# This will run the relevant test if you run the class file. It will not run that code if the class file is just required from elsewhere, though.
#file: path_to_test.rb
# This part is also super easy for unit tests...
require 'test/unit'
class SomeclassTest < Test::Unit::TestCase
def setup
# setup code
end
def test_some_feature
assert something_is_true, "it's not true!"
assert_equal value_youre_expecting, Someclass.new.someemethod("params")
# etc.
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.