This question is Ruby related.
Suppose I want to have the test unit for my class in the same file as it's definition. Is it possible to do so? For example, if I'd pass a "--test" argument when I run the file, I'd want it to run the test unit. Otherwise, execute normally.
Imagine a file like this:
require "test/unit"
class MyClass
end
class MyTestUnit < Test::Unit::TestCase
# test MyClass here
end
if $0 == __FILE__
if ARGV.include?("--test")
# run unit test
else
# run normally
end
end
What code should I have in the #run unit test
section?