I wanted to take a screenshot when a test fails, but, afterwords, run the @After method.
Is it possible to do so? With TestWatcher the method failed() runs after the @After.
Furthermore, I cannot pass the @After content to the TestWatcher finished() because I have a super.afterTest() to call in @After.
Any ideas?
It's impossible for TestWacher methods finished() or failed() to run before the @after method given that TestWatcher is a base class for Rules.
Because of the way that rules are set up, you can't have a rule that comes after @before or before @after. You can think of rules like shells that you put on the test method. The first shell to go on is @before/@after. Thereafter the @rules are applied. (Reference @Troy in Apply '@Rule' after each '@Test' and before each '@After' in JUnit)
The execution order, for one @test, is as follows
@TestWatcher starting
@Before
@Test
@After
@TestWatcher finished
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With