testunit

Run multiple tests in one script in parallel using Ruby Test Unit

房东的猫 提交于 2019-12-04 06:05:06
I have 4 tests in one ruby script, which I run using command ruby test.rb the out put looks like Loaded suite test Started .... Finished in 50.326546 seconds. 4 tests, 5 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed What I want to achieve is, run all the 4 tests in parallel instead of it being sequential. Something like 4 threads each running one test, effectively reducing the execution time to the slowest of the 4 tests +little time of the parallel execution. I came across this , but this seems to run multiple ruby test FILES in parallel - say if i had

can't get test unit startup to work in ruby 1.9.2

大兔子大兔子 提交于 2019-12-04 05:18:04
I am using Ruby 1.9.2 (ruby -v yields :ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]), and I am trying to get this to work: require 'test/unit' class TestStartup < Test::Unit::TestCase def self.startup puts "startup" end def test1 puts "in test1" end end when I run it, I get Loaded suite test_startup Started in test1 . Finished in 0.000395 seconds. 1 tests, 0 assertions, 0 failures, 0 errors, 0 skips I had a hard time finding documentation on this feature, other than scattered posts here on SO and the like. And yes, I want to use this feature and not setup. TIA Ruby 1.9.x bundles

What is the difference between jest.mock(module) and jest.fn()

北战南征 提交于 2019-12-04 04:23:01
I have tried couple different ways of defining the mock function and all of my tries failed. When I try to define it as follow: jest.mock('../src/data/server', ()=> ({server: {report: jest.fn()}})); expect(server.report.mock).toBeCalledWith(id, data, () => {...}, () => {...}); I get the this error: expect(jest.fn())[.not].toBeCalledWith() jest.fn() value must be a mock function or spy. Received: undefined If I define the mock as : var spy = jest.mock('../src/data/server', ()=> ({server: {report: jest.fn()}})); expect(spy).toBeCalledWith(id, data, () => {...}, () => {...}); it returns the

Mocha: stubbing method with specific parameter but not for other parameters

孤者浪人 提交于 2019-12-04 00:10:55
问题 I want to stub a method with Mocha only when a specific parameter value is given and call the original method when any other value is given. When I do it like this: MyClass.any_instance.stubs(:show?).with(:wanne_show).returns(true) I get an unexpected invocation for MyClass.show?(:other_value) I also know, that I can stub all parameters when writing the mock without the ´with´-call and then give my specific mock. But then I have to know the return value for every call, which is not the case :

Test::Unit Rails - How to assert one number is greater than another one?

亡梦爱人 提交于 2019-12-03 14:23:37
问题 I am writing my first unit tests with Test::Unit and I have reached a point where I need to compare two numbers. Much to my surprise, I have discovered that none of the following were available: assert_greater_than assert_lesser_than assert_greater_or_equal_than assert_lesser_or_equal_than Is this normal? How should I do it then? Thanks 回答1: Rather than provide a bunch of different assertions as you suggest, Test::Unit provides the method assert_operator , used like this: assert_operator x, :

How do I inherit abstract unit tests in Ruby?

前提是你 提交于 2019-12-03 14:10:42
问题 I have two unit tests that should share a lot of common tests with slightly different setup methods. If I write something like class Abstract < Test::Unit::TestCase def setup @field = create end def test_1 ... end end class Concrete1 < Abstract def create SomeClass1.new end end class Concrete2 < Abstract def create SomeClass2.new end end then Concrete1 does not seem to inherit the tests from Abstract. Or at least I cannot get them to run in eclipse. If I choose "Run all TestCases" for the

How to color unit tests with lib minitest or Test:Unit?

风格不统一 提交于 2019-12-03 09:03:14
问题 I would like to have unit tests output color in my dev environment. However, I can't make it work on Linux (Debian and Ubuntu). When I include the following libs: require 'minitest/autorun' require 'minitest/unit' require 'minitest/pride' I get: /usr/local/rvm/gems/ruby-1.9.2-p136/gems/minitest-2.3.1/lib/minitest/pride.rb:35:in `<top (required)>': undefined method `output' for MiniTest::Unit:Class (NoMethodError) caused by the code: MiniTest::Unit.output = PrideIO.new(MiniTest::Unit.output) I

How do I inherit abstract unit tests in Ruby?

十年热恋 提交于 2019-12-03 05:06:18
I have two unit tests that should share a lot of common tests with slightly different setup methods. If I write something like class Abstract < Test::Unit::TestCase def setup @field = create end def test_1 ... end end class Concrete1 < Abstract def create SomeClass1.new end end class Concrete2 < Abstract def create SomeClass2.new end end then Concrete1 does not seem to inherit the tests from Abstract. Or at least I cannot get them to run in eclipse. If I choose "Run all TestCases" for the file that contains Concrete1 then Abstract is run even though I do not want it to be. If I specify

Test::Unit Rails - How to assert one number is greater than another one?

蓝咒 提交于 2019-12-03 04:13:12
I am writing my first unit tests with Test::Unit and I have reached a point where I need to compare two numbers. Much to my surprise, I have discovered that none of the following were available: assert_greater_than assert_lesser_than assert_greater_or_equal_than assert_lesser_or_equal_than Is this normal? How should I do it then? Thanks Rather than provide a bunch of different assertions as you suggest, Test::Unit provides the method assert_operator , used like this: assert_operator x, :>, y assert_operator x, :>=, y etc. How about this simple thing, assert x>y Here are some functions you can

How to color unit tests with lib minitest or Test:Unit?

心不动则不痛 提交于 2019-12-02 23:14:50
I would like to have unit tests output color in my dev environment. However, I can't make it work on Linux (Debian and Ubuntu). When I include the following libs: require 'minitest/autorun' require 'minitest/unit' require 'minitest/pride' I get: /usr/local/rvm/gems/ruby-1.9.2-p136/gems/minitest-2.3.1/lib/minitest/pride.rb:35:in `<top (required)>': undefined method `output' for MiniTest::Unit:Class (NoMethodError) caused by the code: MiniTest::Unit.output = PrideIO.new(MiniTest::Unit.output) I have seen a working Rspec variant . Unfortunately, my Ruby knowledge is not enough to see differences.