Executing tests

Running tests

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 :

test-form

While it is convenient to launch test on demand manually, 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).

Test parameters

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 Service Version.

Test Endpoint

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:

http[s]://{service.endpoint.url:port}/{service.path}

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:

kafka://{kafka.broker.url:port}/{kafka.topic.name}

Test Runner

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
HTTP REST and SOAP Simplest test runner that only checks that valid target endpoints are deployed and available: returns a 20x or 404 Http status code when appropriated. This can be called a simple “smock test”.
SOAP 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.
SOAP_UI REST and SOAP When the microservice mock repository is defined using SoapUI: ensures that assertions put into Test cases are checked valid. Report failures.
POSTMAN REST When the microservice mock repository is defined using Postman: executes test scripts as specified within Postman. Report failures.
OPEN_API_SCHEMA 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.
ASYNC_API_SCHEMA 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.

Timeout

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.

Secret

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.

test-history

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 :

test-details

“Executing tests” was last updated: September 2, 2019
Improve this page