vendredi 24 juin 2016

Using the best practice in API test setup - DB communication needed (TDD)

I am going to write a new endpoint to unlock the domain object, something like:

../domainObject/{id}/unlock

As I apply TDD, I have started to write an API test first. When the test fails, I am going to start writing Integration and Unit tests and implement the real code.

In API test, I need a locked domain data for test fixture setup to test the unlock endpoint that will be created. However, there is no endpoint for locking the domain object on the system. (our Quartz jobs lock the data) I mean, I need to create a data by using the database directly.

I know that in API test, straight forwardly database usage is not the best practice. If you need a test data, you should call the API too. e.g.

../domainObject/{id}/lock

Should this scenario be an exception in this case? Or is there any other practice should I follow?

Thanks.

Aucun commentaire:

Enregistrer un commentaire