unit/test : I don't want to automatically run all tests

  • Thread starter Raphael Bauduin
  • Start date
R

Raphael Bauduin

Hi,

I'm writing some unit tests and the plan is to let them run each night, and producing a little
web page summarizing the results.

I've written my tests, put them in a suite, and want to run them, but collect the results
to build the web page afterwards. I use this code:

result = Test::Unit::TestResult.new()
MyTestClass.suite.run(result) {|s, name| puts "Status=#{s} and name = #{name}"}

This runs absolutely fin, but test/unit then automatically starts to run all tests define in the file.
This is a feature of test/unit (as noted at http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/index.html and
at http://www.rubygarden.org/ruby?UsingTestUnit), but I really don't need it here. Can I turn this behaviour off?

Thanks.

Raph
 
G

Gennady Bystritksy

When you terminate your test runner with exit!, test/unit will not have
a chance to run tests on its own.

Gennady.
 
R

Raphael Bauduin

Gennady said:
When you terminate your test runner with exit!, test/unit will not have
a chance to run tests on its own.

yep, that's what I've found as solution, but I thought there was a better way :)

Raph
 
D

Dick Davies

* Raphael Bauduin said:
Hi,

I'm writing some unit tests and the plan is to let them run each night, and
producing a little
web page summarizing the results.

I've written my tests, put them in a suite, and want to run them, but
collect the results to build the web page afterwards. I use this code:

result = Test::Unit::TestResult.new()
MyTestClass.suite.run(result) {|s, name| puts "Status=#{s} and name =
#{name}"}

Look at the (source of ) TestTask in rake (http://rake.rubyforge.org), that provides a
means of running a named test rather than the lot.
 
A

Alan Chen

If you define test sets in different files, yet another way is
controlling what tests are defined via selective requires.
 
A

Alan Chen

If you define test sets in different files, yet another way is
controlling what tests are defined via selective requires.
 
N

Nathaniel Talbott

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top