0

JUnit @Rule TemporaryFolder will delete the folder in case there is an Exception during execution of the test.

For my testing purposes I created my custom @Rule MyTemporaryFolder which is essentially the same except for when the exception happens it will save the temporary folder so the internals of the folder can be examined (basically any test output).

So now I have to write unit tests for my custom @Rule class. How can I do it? How can I simulate test starting and finishing inside of another test so I can check if my temporary folder was deleted properly (or is still there)?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Viktar Kava
  • 761
  • 1
  • 5
  • 10
  • Just call the appropriate methods on your rule in your test methods. – M. Deinum Dec 14 '16 at 08:39
  • You could advise JUnit to store the temporary folder on the Desktop (or somewhere else). You can debug your tests and see how the folder appears/disappears. On how to write tests with @Rule please refer to one of the various tutorials in the internet. – Chris311 Dec 14 '16 at 11:00
  • This is a duplicate of [this](http://stackoverflow.com/questions/27042951/eclemma-code-coverage-plugin-and-powermockrunner). – Chris311 Dec 14 '16 at 12:01

0 Answers0