문제

How on earth do I use the after_run class function to run some code after all my tests are done? All my attempts raise NoMethodError:

class MyTest < Minitest::Test
  after_run {
    puts "After run!"
  }
end

# -------------------------------------------------------------------------------

class MyTest < Minitest::Test
  self.after_run {
    puts "After run!"
  }
end

# -------------------------------------------------------------------------------

class MyTest < Minitest::Test
end

MyTest.after_run {
  puts "After run!"
}

Using Minitest 5.2.2

도움이 되었습니까?

해결책

I assumed after_run would run after all the tests in the class, but as Sergio Tulentsev pointed out, it runs after the whole test suite is complete. For the sake of completeness, this is how it's used:

Minitest.after_run {
  puts "The whole test suite is complete"
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top