Skip to content

Instantly share code, notes, and snippets.

@myokoym
Created February 15, 2015 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myokoym/3a1307982095a009125c to your computer and use it in GitHub Desktop.
Save myokoym/3a1307982095a009125c to your computer and use it in GitHub Desktop.
test-unitで指定したテストだけ実行する方法 ref: http://qiita.com/myokoym/items/2c3559ec0e060b7ec943
$ ruby test_user.rb
Loaded suite test_user
Started
..
Finished in 0.000777458 seconds.
------
2 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
------
2572.49 tests/s, 2572.49 assertions/s
$ ruby test_user.rb -v
Loaded suite test_user
Started
UserTest:
test_full_name: .: (0.000200)
ProfileTest:
test_has_profile: .: (0.000144)
Finished in 0.000863226 seconds.
------
2 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
------
2316.89 tests/s, 2316.89 assertions/s
$ ruby test_user.rb -v -n test_full_name
Loaded suite test_user
Started
UserTest:
test_full_name: .: (0.000314)
Finished in 0.000953645 seconds.
------
1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
------
1048.61 tests/s, 1048.61 assertions/s
$ ruby test_user.rb -v -n test_has_profile
Loaded suite test_user
Started
UserTest:
ProfileTest:
test_has_profile: .: (0.000220)
Finished in 0.000694584 seconds.
------
1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
------
1439.71 tests/s, 1439.71 assertions/s
$ ruby test_user.rb -v -n "/test_full_name|test_has_profile/"
Loaded suite test_user
Started
UserTest:
test_full_name: .: (0.000208)
ProfileTest:
test_has_profile: .: (0.000140)
Finished in 0.00091056 seconds.
------
2 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
------
2196.45 tests/s, 2196.45 assertions/s
$ ruby test_user.rb --help
Test::Unit automatic runner.
Usage: test_user.rb [options] [-- untouched arguments]
-r, --runner=RUNNER Use the given RUNNER.
(c[onsole], e[macs], x[ml])
--collector=COLLECTOR Use the given COLLECTOR.
(de[scendant], di[r], l[oad], o[bject]_space)
-n, --name=NAME Runs tests matching NAME.
Use '/PATTERN/' for NAME to use regular expression.
--ignore-name=NAME Ignores tests matching NAME.
Use '/PATTERN/' for NAME to use regular expression.
-t, --testcase=TESTCASE Runs tests in TestCases matching TESTCASE.
Use '/PATTERN/' for TESTCASE to use regular expression.
--ignore-testcase=TESTCASE Ignores tests in TestCases matching TESTCASE.
Use '/PATTERN/' for TESTCASE to use regular expression.
--location=LOCATION Runs tests that defined in LOCATION.
LOCATION is one of PATH:LINE, PATH or LINE
--attribute=EXPRESSION Runs tests that matches EXPRESSION.
EXPRESSION is evaluated as Ruby's expression.
Test attribute name can be used with no receiver in EXPRESSION.
EXPRESSION examples:
!slow
tag == 'important' and !slow
--[no-]priority-mode Runs some tests based on their priority.
--default-priority=PRIORITY Uses PRIORITY as default priority
(h[igh], i[mportant], l[ow], m[ust], ne[ver], no[rmal])
-I, --load-path=DIR[:DIR...] Appends directory list to $LOAD_PATH.
--color-scheme=SCHEME Use SCHEME as color scheme.
(d[efault])
--config=FILE Use YAML fomat FILE content as configuration file.
--order=ORDER Run tests in a test case in ORDER order.
(a[lphabetic], d[efined], r[andom])
--max-diff-target-string-size=SIZE
Shows diff if both expected result string size and actual result string size are less than or equal SIZE in bytes.
(1000)
-v, --verbose=[LEVEL] Set the output level (default is verbose).
(important-only, n[ormal], p[rogress], s[ilent], v[erbose])
--[no-]use-color=[auto] Uses color output
(default is auto)
--progress-row-max=MAX Uses MAX as max terminal width for progress mark
(default is auto)
--no-show-detail-immediately Shows not passed test details immediately.
(default is yes)
--output-file-descriptor=FD Outputs to file descriptor FD
-- Stop processing options so that the
remaining options will be passed to the
test.
-h, --help Display this help.
Deprecated options:
--console Console runner (use --runner).
$ ruby test_user.rb -v -t "/Profile/"
Loaded suite test_user
Started
UserTest:
ProfileTest:
test_has_profile: .: (0.000241)
Finished in 0.000762848 seconds.
------
1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
------
1310.88 tests/s, 1310.88 assertions/s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment