-
David Diederich authoredDavid Diederich authored
#Integration tests The integration tests are a separate project in the same repo. This allows you to run the notification service locally and then run the integration tests against them.
This implementation offers a highly opinionated option.
For each API method you create a new RestDesciptor and TestTemplate. The RestDescriptior describes how to call you API and you then choose a TestTemplate to inherit from which has the test suite for your descriptor.
The TestTemplates have common tests needed for common scenarios e.g. Get by Id, Delete, Create as well as the BaseTEstTemplate that has common tests for all scenarios e.g. cross partition access.
These classes offer the standard set of tests expected by our APIs. Overriding these classes and using descriptors means you automatically get these tests for free. As a minimum you need a Create and Delete API for any resource. This enables setup and cleanup to happen after the test is run.
You could override these classes and they will offer all the tests your API needs. See the classes in the namespace com.slb.api.resource for implementation details e.g. ResourceCreateApiTest.java
This proves your API is functioning correctly and then the unit tests provide the breadth of testing needed for different scenarios.
The BaseTest classes are
BaseTestTemplate.java - offers test that every API uses including access pattern tests, HTTPS enforcement test, Options method test, 20X response on a valid call etc.
CreateApiTestTemplate.java - Extra tests needed by APIs that create a resource e.g. REturns 409 conflict when resource already exists.
DeleteApiTestTemplate.java - Extra tests need by APIs that retrieve a resource by id e.g. 404 response when resource doesnt exist.
RetrieveApiTestTemplate.java - Extra tests needed by APIs that retrieve a resource by id e.g. 404 response when resource doesnt exist.
There are obviously other API types that are not included here e.g. list, query etc. These can be created directly of the BaseTest class or you can provide test templates for these API to be added..
Using these directly or just as documentation for your own tests means that your APIs are consistent with our standards and the other APIs in the Ecosystem.