Microcks offers mocks but can also be used for Contract testing of API or services being under development. You spend a lot of time describing request/response pairs and matching rules: it would be a shame not to use this sample as test cases once the development is on its way!
From the page displaying basic information on your microservice mocks, you have the ability to launch new tests against different endpoints that may be representing different environment into your development process. Hitting the NEW TEST… button, leads you to the following form where you will be able to specify an target URL for test, as well as a Runner - a testing strategy for your new launch :
While it is convenient to launch test
on demandmanually, it may be interesting to consider launching new tests automatically when a new deployment of the application occurs for example… Microcks allows you such automation by offering API for ease of integration. See here for more details).
Service under test
Service under test is simply the reference of the API/Service specification we’d like to test. This a couple of
Service Name and
The Test Endpoint is simply a URI where a deployed component is providing API specification endpoint. In the testing litterature, this is usually defined as the URI of the System Under Test.
For HTTP based APIs (REST or SOAP), this is a simple URL that should respect following pattern:
For Event based API through Async API testing, here is below the list of supported patterns depending on the protocole binding you’d like to test:
As stated above, Microcks offers different strategies for running tests on endpoints where our microservice being developed are deployed. Such strategies are implemented as Test Runners. Here are the default Test Runners available within Microcks:
|Test Runner||API/Service Types||Description|
||REST and SOAP||Simplest test runner that only checks that valid target endpoints are deployed and available: returns a
||SOAP||Extension of HTTP Runner that also checks that the response is syntactically valid regarding SOAP WebService contract. It realizes a validation of the response payload using XSD schemas associated to service.|
||REST and SOAP||When the microservice mock repository is defined using SoapUI: ensures that assertions put into Test cases are checked valid. Report failures.|
||REST||When the microservice mock repository is defined using Postman: executes test scripts as specified within Postman. Report failures.|
||REST||When the microservice mock repository is defined using Open API: it executes example requests and check that results have the expected Http status and that payload is compliant with JSON / OpenAPI schema specified into OpenAPI specification.|
||EVENT||When the microservice mock repository is defined using Async API: it connects to specified broker endpoints, consume messages and check that payload is compliant with JSON / AsyncAPI schema specified into AsyncAPI specification.|
Depending on the type of Service or Tests you are running, the specification of a Timeout maybe mandatory. This is a numerical value expressed in millieseconds.
Depending on the Test Endpoint you are connecting to, you may need additional authenticatoin information - like credentials or custom X509 Certificates. You may reuse External Secrets that has been made available in the Microcks installation by the admnistrator.
Getting tests history and details
Tests history for an API/Service is easily accessible from the microservice summary page. Microcks keep history of all the launched tests on an API/Service version. Success and failures are kept in database with unique identifier and test number to allow you to compare cases of success and failures.
Specific test details can be visualized : Microcks also records the request and response pairs exchanged with the tested endpoint so that you’ll be able to access payload content as well as header. Failures are tracked and violated assertions messages displayed as shown in the screenshot below :