class TestSomeClass < Test::Unit::TestCase
def setup
# some setup
end
def test_01_firstTest
# some assertion
end
def test_02_secondTest
# some other assertion
end
end
When I’m running the script, I’m doing like this:
ruby myscript.rb -v
I see there all tests that are in my testcase.
Till now, no problem.
But I want to display (yes, just to display) my available tests from a
testcase.
Is this possible ?
If not, how there is possible to add extra parameters to command line in
order to display all tests ?
class TestSomeClass < Test::Unit::TestCase
def setup
# some setup
end
def test_01_firstTest
# some assertion
end
def test_02_secondTest
# some other assertion
end
end
But I want to display (yes, just to display) my available tests from a
testcase.
Is this possible ?
Is this what you are after:
require “test/unit”
class TestSomeClass < Test::Unit::TestCase
def setup
# some setup
end
def test_01_firstTest
# some assertion
end
def test_02_secondTest
# some other assertion
end
end
method_names = TestSomeClass.public_instance_methods
test_methods = method_names.find_all do |method_name|
method_name.index(“test”) == 0
end
puts test_methods
–output:–
test_01_firstTest
test_02_secondTest
Loaded suite r3test
Started
…
Finished in 0.00037 seconds.
class TestSomeClass < Test::Unit::TestCase
def setup
# some setup
end
def test_01_firstTest
# some assertion
end
def test_02_secondTest
# some other assertion
end
end
But I want to display (yes, just to display) my available tests from a
testcase.
Is this possible ?
Is this what you are after:
require “test/unit”
class TestSomeClass < Test::Unit::TestCase
def setup
# some setup
end
def test_01_firstTest
# some assertion
end
def test_02_secondTest
# some other assertion
end
end
method_names = TestSomeClass.public_instance_methods
test_methods = method_names.find_all do |method_name|
method_name.index(“test”) == 0
end
puts test_methods
–output:–
test_01_firstTest
test_02_secondTest
Loaded suite r3test
Started
…
Finished in 0.00037 seconds.
2 tests, 0 assertions, 0 failures, 0 errors
Hi,
Thanks for your reply.
The problem wasn’t really how to display methods.
“If not, how there is possible to add extra parameters to command line
in
order to display all tests ?”
I want to add extra command line arguments to my script, but in an
elegant way.
Arguments like -n, -t, -v, etc. that already exists in TestCase.
Thanks for your reply.
The problem wasn’t really how to display methods.
“If not, how there is possible to add extra parameters to command line
in
order to display all tests ?”
I want to add extra command line arguments to my script, but in an
elegant way.
Arguments like -n, -t, -v, etc. that already exists in TestCase.
Then why did you say this:
I want to display (yes, just to display) my available tests from a
testcase.
Is this possible ?
If not, how there is possible to add extra parameters to command line in
order to display all tests ?
Your first choice of solutions was “I want to display the methods”.
Then “if that is not possible”, “how there is possible to add extra
parameters to command line…”
class TestSomeClass < Test::Unit::TestCase
def setup
# some setup
end
def test_01_firstTest
# some assertion
end
def test_02_secondTest
# some other assertion
end
end
But I want to display (yes, just to display) my available tests from a
testcase.
Is this possible ?
Is this what you are after:
require “test/unit”
class TestSomeClass < Test::Unit::TestCase
def setup
# some setup
end
def test_01_firstTest
# some assertion
end
def test_02_secondTest
# some other assertion
end
end
method_names = TestSomeClass.public_instance_methods
test_methods = method_names.find_all do |method_name|
method_name.index(“test”) == 0
end
puts test_methods
–output:–
test_01_firstTest
test_02_secondTest
Loaded suite r3test
Started
…
Finished in 0.00037 seconds.
2 tests, 0 assertions, 0 failures, 0 errors
Hi,
Thanks for your reply.
The problem wasn’t really how to display methods.
“If not, how there is possible to add extra parameters to command line
in
order to display all tests ?”
I want to add extra command line arguments to my script, but in an
elegant way.
Arguments like -n, -t, -v, etc. that already exists in TestCase.
Thanks.
Alin
Unfortunately, there is no command line option to do what you want. If
you want to see the available command line options, run a test with the
‘–help’ option. You’ll see something like this:
-r, --runner=RUNNER Use the given RUNNER.
(c[onsole], f[ox], g[tk], g[tk]2,
t[k])
-n, --name=NAME Runs tests matching NAME.
(patterns may be used).
-t, --testcase=TESTCASE Runs tests in TestCases matching
TESTCASE.
(patterns may be used).
-v, --verbose=[LEVEL] Set the output level (default is
verbose).
(s[ilent], p[rogress], n[ormal],
v[erbose]) – Stop processing options
so that the
remaining options will be passed to
the
test.
-h, --help Display this help.