Created
April 2, 2016 14:41
-
-
Save kaosf/b4d3d3140e0f32119a2d1f8fc7cc4c23 to your computer and use it in GitHub Desktop.
Test cases nesting for test-unit gem like a describe/context nesting of RSpec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# At first, run `gem install test-unit`. | |
require 'test/unit' | |
class TestA < Test::Unit::TestCase | |
setup { puts "all setup" } | |
test("a") { assert true } | |
sub_test_case "a sub" do | |
setup { puts "a sub setup" } | |
sub_test_case "a sub sub1" do | |
setup { puts "a sub sub1 setup" } | |
test("a sub sub1") { assert true } | |
end | |
sub_test_case "a sub sub2" do | |
setup { puts "a sub sub2 setup" } | |
test("a sub sub2") { assert true } | |
end | |
end | |
end | |
#=> | |
# Loaded suite test_a | |
# Started | |
# all setup | |
# .all setup | |
# a sub setup | |
# a sub sub1 setup | |
# .all setup | |
# a sub setup | |
# a sub sub2 setup | |
# . | |
# | |
# Finished in 0.00419507 seconds. | |
# ---------------------------------------------------------------------------------------------------------------------------------------- | |
# 3 tests, 3 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications | |
# 100% passed | |
# ---------------------------------------------------------------------------------------------------------------------------------------- | |
# 715.13 tests/s, 715.13 assertions/s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment