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