testunit

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

自古美人都是妖i 提交于 2019-12-21 15:03:31
问题 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

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

蓝咒 提交于 2019-12-21 12:41:10
问题 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

How to include unit tests in a ruby module?

。_饼干妹妹 提交于 2019-12-19 03:19:05
问题 I'm trying to include the unit tests for a module in the same source file as the module itself, following the Perl modulino model. #! /usr/bin/env ruby require 'test/unit' module Modulino def modulino_function return 0 end end class ModulinoTest < Test::Unit::TestCase include Modulino def test_modulino_function assert_equal(0, modulino_function) end end Now, I can run the unit-tests executing this source file. But , they are also run when I require/load them from another script. How can this

How to include unit tests in a ruby module?

ぃ、小莉子 提交于 2019-12-19 03:16:11
问题 I'm trying to include the unit tests for a module in the same source file as the module itself, following the Perl modulino model. #! /usr/bin/env ruby require 'test/unit' module Modulino def modulino_function return 0 end end class ModulinoTest < Test::Unit::TestCase include Modulino def test_modulino_function assert_equal(0, modulino_function) end end Now, I can run the unit-tests executing this source file. But , they are also run when I require/load them from another script. How can this

How to output names of ruby unit tests

北城以北 提交于 2019-12-18 11:53:37
问题 I have a unit test (example is modified Test::Unit documentation) require 'test/unit' class TC_MyTest < Test::Unit::TestCase def test_something assert(true) end end When I execute it, I get: Loaded suite C:/test Started . Finished in 0.0 seconds. 1 tests, 1 assertions, 0 failures, 0 errors I would like to get something like this ( test_something is outputted): Loaded suite C:/test Started test_something . Finished in 0.0 seconds. 1 tests, 1 assertions, 0 failures, 0 errors 回答1: If you're

How can you perform functional tests on JavaScript responses?

天大地大妈咪最大 提交于 2019-12-13 06:59:29
问题 I noticed that it is quite common in Rails to render back text for js requests with the text embedded within a jquery method call to insert it into the DOM. // javascript code $.getScript("/some_url"); // rails partial code, to make things more clear I have added some simple html $("#some_id").text(unescape_javascript('<div id="foo">bar</div>')) My question is how do you perform assert_select, or the equivalent, within a functional test on response text like this? // class

Where to start with test driven development?

断了今生、忘了曾经 提交于 2019-12-13 04:37:07
问题 I'm relatively new to Test Driven Development, and I was just wondering where I should start? I understand how to do the testing. I just mean what should I test first? Is there a best practice for this? Should I test the models first? The controllers? Should I write an integration test first thing, then build everything up from there to make it pass? What are the opinions on this? 回答1: I don't think there's one hard and fast answer on where to start. I personally like to start with my UI

stub an instance variable using mocha

亡梦爱人 提交于 2019-12-13 03:38:30
问题 Let's say I have a method that references an instance variable directly: class MyClass def method1 puts @instance_var end end How can I stub out the value of @instance_var using mocha in a Test::Unit test? 回答1: You can't. That's one of the many reasons why you should never access ivars directly. 来源: https://stackoverflow.com/questions/9971192/stub-an-instance-variable-using-mocha

Is it possible to enhance the rake test task and merge test results together?

妖精的绣舞 提交于 2019-12-12 09:22:51
问题 I am writing tests for my sidekiq workers and I want them to run when I type "rake" in the terminal. I have that working - I added the following to my Rakefile: namespace :test do Rake::TestTask.new(:workers) do |t| t.libs << "test" t.pattern = 'test/workers/**/*_test.rb' end end Rake::Task[:test].enhance ["test:workers"] When I run rake I get something like this as my output: Run options: --seed 51172 # Running tests: SS Finished tests in 0.005594s, 357.5259 tests/s, 0.0000 assertions/s. 2

How can a person toggle the use of transactional_fixtures for one set of tests using Test::Unit?

半世苍凉 提交于 2019-12-11 11:16:24
问题 I have some thinking-sphinx tests that I need to turn off transactions for to prevent mysql locks, but in doing so I break a lot of other tests previously written, so I need to be able to toggle the setting. I have found similar questions regarding rspec, but none for Test::Unit. I have tried self.use_transactional_fixtures = false which is what allows the sphinx tests to pass, but causes others to break. I am sure I could set that to true in all the other tests, but that would also require