3 ms·
This is pretty similar to my approach. In the context of developing an API I use integration tests more than unit tests. It is straightforward to spin up an app
by vbsteven 8y ago
This is pretty similar to my approach. In the context of developing an API I use integration tests more than unit tests. It is straightforward to spin up an application server against a test database with some test data. Run some example requests against it and verify the results.
I frequently have Test classes which contain a full scenario related to a specific resource or action. For example:
* create resource
* lookup resource
* modify resource
* list all resources
* delete resource
The JSON files for the integration tests are then used as examples in the API documentation.
Unit tests are reserved mostly for verifying business logic components. There is no need to setup a complex ControllerTest with mocked out Services or Repositories as you don't care about the internals anyway. Just the input vs output and the integration tests cover those already.