I have a microservice that provides basic CRUD operations on top of a database with some extra logic. I want to write an integration test to test that API work as it should by deploying the microservice and issuing the REST calls and analyzing the returns. There is some open discussion about how to approach database cleanup with 2 particular option:
- Make a generic @BeforeClass/@BeforeMethod method in common superclass that will delete the all the data from the database to "setup" clean environment for the test (makes integration test "framework" dependent on the environment)
- Make every test clean after itself by issuing delete REST requests for the data saved by the test in the @AfterClass/@AfterMethod (makes extra code in every test)
Is any of the 2 options more preferable? Or is there 3rd?
Aucun commentaire:
Enregistrer un commentaire