How it works...
In this recipe, we covered how to create unit tests for our services. In this particular example, we are testing our token service with two tests: one for the retrieveToken call and the other one for the validateToken call. In order to create an instance of our service, we use the ServiceTest helper class. This class manages all internals to bring up a server running your service in memory. By default, ServiceTest does not support using persistence, clustering, or pubsub. If they are required for your use case, they need to be enabled by updating the provided Setup object. With our service running, we need something to access it and use it. We can achieve that thanks to the service client. It's the server that provides the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access