Вопрос

I'm using a rake task to run the test suites of my application.
I can see that when I launch the task it run the command

ruby -I"lib:test" -I"[...]/lib" "[...]/lib/rake/rake_test_loader.rb" "vendor/plugins/shop/test/**/*_test.rb"

Where [...] is the path to the rake gem in my gemset.

When I run the task, I got some warnings and some . which means some tests pass but I end up with terminated

Log example :

...................................... 7431 Terminated

Notice that 7431 is the PID.

I cannot find any information about this case, verbose or trace option do not help me to figure out where my test suite is broken.

Is anybody knows what can I do to fix this ?

Это было полезно?

Решение

I don't know, what process creates the "Terminated"-message, but you could try the following:

Add a

def setup
  puts "Start test #{self.__name__}"
  STDOUT.flush
end
def teardown
  puts "Finished test #{self.__name__}"
  STDOUT.flush
end

to all of your tests.

Example:

require 'test/unit'

class Mytest < Test::Unit::TestCase
  def test_1
    assert_equal(1,1)
  end
  def test_2
    assert_equal(1,1)
    exit 1  ##stops the execution
  end
  def test_3
    assert_equal(1,1)
  end
end

results in

Loaded suite test
Started
.>Exit code: 1

The test is stopped and you don't see where. I hope this is a similar situation to your "Terminate"-message.

Now add some code:

require 'test/unit'

class Mytest < Test::Unit::TestCase
  def setup
    puts "Start test #{self.__name__}"
    STDOUT.flush
  end
  def teardown
    puts "Finished test #{self.__name__}"
    STDOUT.flush
  end
  def test_1
    assert_equal(1,1)
  end
  def test_2
    assert_equal(1,1)
    exit 1  ##stops the execution
  end
  def test_3
    assert_equal(1,1)
  end
end

This results in:

Loaded suite test
Started
Start test test_1
Finished test test_1
.Start test test_2
Finished test test_2

The last mentioned test_2 is the one with the problem.

You may also add the setup and teardown to each TestCase (but if you have own definitions ot setup/teardown they will not contain the testcode).

require 'test/unit'

class Test::Unit::TestCase
  def setup
    puts "Start test #{self.__name__}"
    STDOUT.flush
  end
  def teardown
    puts "Finished test #{self.__name__}"
    STDOUT.flush
  end
end

Don't forget to remove the code - it is only to identify where your problem may be.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top