Ruby minitest assert_output syntax

流过昼夜 提交于 2019-12-01 04:42:36

In order for your test method to run, the method name needs to start with test_. Also, the way assert_output works is that the block will write to stdout/stderr, and the arguments will be checked if they match stdout/stderr. The easiest way to check this IMO is to pass in a regexp. So this is how I would write that test:

class TestTestClass < MiniTest::Unit::TestCase 
  def setup
    @test = TestClass.new
  end

  def test_output_produces_output
    assert_output(/hey/) { @test.output}
  end   
end 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!