Instructional strategies for TestingMicroservices with ArquillianObjectives•Implement a microservice test case using Arquillian.18JB283-RHOAR1.0-en-1-20180517
Presentation NotesPresentation NotesIntroductionThis section introduces Arquillian, a testing framework that starts up WildFly Swarm to enable allthe facilities from MicroProfile specification, such as the context and dependency injection (CDI)container and the RESTEasy runtime environment. Arquillian is a wide subject and we will keepthe presentation short to avoid going into the details.LectureFor audiences with some Arquillian knowledge, you must just stress the @CreateSwarmannotation. It configures the variables needed by WildFly Swarm to start, such as port numbersand logging facilities. It is important to mention the @Deploymentclass-level annotationhowever it is also important to enforce that for this course this annotation would not workbecause the classes from a single microservice are not stored in a segregated package.For audiences without Arquillian knowledge, mention that Arquillian triggers not only the WildFlySwarm infrastructure, but it may be used for other containers as well, such as EAP, WebSphere,WebLogic, among other options. Walk through the source code in the demo to make sure theyunderstand how WildFly Swarm is started and how the tests are emulating an external call.DemonstrationThe idea in the demonstration is to use Arquillian's extension to package the resulting file todeploy it on WildFly Swarm. Initially, you need to create a WebArchive object that containsall the dependencies, classes, and configuration files used by WildFly Swarm to start up theinfrastructure. Later you will discuss the test, using some test extensions to simplify the RESTendpoint invocations.Guided ExerciseTell your students to turn to the guided exercise in their books. When the students havecompleted the exercise, discuss the activity and solution. The tests take some time to start andrun, so please be patient with the them.SummaryMicroservices testing with MicroProfile implementation requires the startup of the wholemicroservice to test it properly. Use Arquillian to simplify this task.Instructional strategies for TestingMicroservices with Mock FrameworksObjectives•Implement a microservice test using mock frameworks.JB283-RHOAR1.0-en-1-2018051719
Chapter4.Testing MicroservicesPresentation NotesIntroductionTesting REST endpoints that are connected with other microservices mandates you to createa clean and readable test. Unfortunately, invoking the REST endpoints may become a messdue to the REST client API calls. To minimize the confusion, use REST Assured, which uses anelegant but readable fluent interface. Also, for microservice endpoints that depends on externalmicroservices, use WireMock. It starts a web server that responds to the requests made to aREST endpoint. Finally, to test source code implementation on an integration test, you may useMockito, that emulates responses from an API.