MockServer has a UI that can be used to view the internal state within MockServer, including:
The UI is available for all versions of MockServer except the deployable WAR
The UI can be opened in any browser using the URLhttp(s)://<host>:<port>/mockserver/dashboard
For example if MockServer is running on localhost on port 1080 use http://localhost:1080/mockserver/dashboard
MockServerClient or ClientAndServer
The UI can be opened by using the openUI() function on the MockServerClient or ClientAndServer.
The UI is launched using the default browser which the JVM determines from the operating system.
The openUI() method pauses for 1 second after launching the browser to allow the UI to launch and start collecting logs, this ensures that the log are visible in the UI even if MockServer is shutdown quickly by a test shutdown function, such as After, AfterClass, AfterAll, etc. The pause period can be configured using the method openUI(TimeUnit timeUnit, long pause).
To simplify debugging request matching when multiple instances of MockServer are created if the logLevel is set to DEBUG and the launchUIForLogLevelDebug configuration property is enabled (default: false) the ClientAndServer constructor or static factor methods will launch the UI so that it is possible to see all logs events for every instance of MockServer.
The logs section list all the logs events recorded by MockServer, including errors, request matching, exception creation, deletion, etc, as shown below:
To simplify the process of understand how each request is handled and which expectation have or have not been matched all logs events for a single request are grouped together.
In addition, to simplify the process or understand why a given expectation has or has not been matched a because section is shown for any EXPECTATION_NOT_MATCHED this can be expanded to show the full details of which properties did or did not match.
When logLevel is set to DEBUG:
- a detailed reason will be included (see white text in image below)
- clear does not delete logs from the event log, this allows the UI to continue to display logs that would have otherwise been deleted to improve the ability to debug issues
The active expectations section shows all active expectations in the order they are applied, taking into account all factors such as when the expectation was created, its priority, its timeToLive and its times
The received request section shows all request received in the order were received.
The list includes request that are matched against an expectation, requests that are proxied and request that are not proxied or matched against any expectation.
The proxied requests section shows request that have been proxied the corresponding response returned.