vendredi 10 janvier 2020

If an exception is thrown in the @BeforeEach method, will @AfterEach still run

In my tests, I have data setup (which is a series of different entities) that happens in the @BeforeEach method. I clean up that data in the @AfterEach method. Now if an exception were to be thrown during the creation of any of those entities, will the @AfterEach method run? Currently I have a workaround with a try/catch block in my @BeforeEach method, but it would reduce some code duplication if the @AfterEach method takes care of it for me.

Aucun commentaire:

Enregistrer un commentaire