Before all tests, it's needed to insert data into database.
After all tests, it's needed to remove all data from database.
In TestNG it's possible to do such stuff using @BeforeSuite and @AfterSuite.
How to do such stuff in JUnit 5?
In Junit 5 @BeforeAll annotation marks a method to run before all tests in a class.
@AfterAll annotation marks a method to run after all tests in a class.
I found following solution on stackoverflow:
https://stackoverflow.com/a/51556718/6643395
But:
- it works only for Before all tests, not After all tests
- it is needed to annotate each test class with this extension. And that is not good. In my project all test classes extend some base test class. So, why not do this stuff in one place?