簡體   English   中英

如何找到導致瑞克測試任務終止的文件/測試?

[英]How find the file/test which is causing rake test task to terminate?

我正在使用rake任務來運行應用程序的測試套件。
我可以看到,當我啟動任務時,它將運行命令

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

其中[...]是的路徑在我的寶石耙寶石。

運行任務時,我得到一些警告和一些警告. 這意味着一些測試通過了,但我最終terminated

日志示例:

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

注意7431是PID。

我找不到有關這種情況的任何信息,詳細或跟蹤選項無法幫助我確定測試套件的損壞位置。

有誰知道我該怎么做才能解決此問題?

我不知道,什么過程創建了“終止”消息,但是您可以嘗試以下操作:

添加一個

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

進行所有測試。

例:

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

結果是

Loaded suite test
Started
.>Exit code: 1

測試已停止,您看不到哪里。 我希望這與您的“終止”消息類似。

現在添加一些代碼:

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

結果是:

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

最后提到的test_2是有問題的那個。

您也可以將setupteardown添加到每個TestCase(但是,如果您有自己的設置/拆卸定義,則它們將不包含測試代碼)。

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

不要忘記刪除代碼-只是確定問題所在。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM