how to dermine if a test failed in afterEach of a FunSpec in scalatest

后端 未结 1 565
再見小時候
再見小時候 2021-01-16 03:31

In scalatest using FunSpec I have some code that fires in the afterEach. I would like to execute some code to get a screenshot only when the test fails. Just about everythin

相关标签:
1条回答
  • 2021-01-16 03:46

    pretty sure I figured it out. coming from a TestNG background it seemed weird to have to mess with fixtures to accomplish it. I suspect others with a background like mine may also look in all the wrong places as well, so going to leave this here to help others:

    override def withFixture(test: NoArgTest) = { // after
       val outcome = super.withFixture(test)
       outcome match {
         case Failed(ex) =>
         // log ex (the exception) and a screenshot
       }
       outcome
    }
    
    0 讨论(0)
提交回复
热议问题