Disclaimer This post is part of the same presentation given by myself and at the JavaOne Conference 2017 in San Francisco. Bruno Souza Although extremely important, we are not talking here about unit testing and integration testing, assuming you already know what it is and already apply it, as a developer concerned about the quality of your code. Test Automation Pyramid and Agile Testing Quadrants Creating tests is the easiest and quickest way to test your application and ensure that if any bug appears, you will find it before your client. Currently, we cannot talk about testing without talking about test automation. The application of the test automation gives a quick feedback to the team and maintains the execution of the continuously. regression tests The approach we can use to take a greater speed in automating, executing and having a rapid feedback of the tests is the application of the , which is a guide for the application of automation in at least three levels: , and (user interface). Test Pyramid unit services ui The services layer is being divided into three parts: , tests and . component tests integration API tests The is the most important layer of our application because we will create tests for the code that we are developing and guarantee its work as expected, even after future maintenance (recommending the use of ). In this layer, we can apply analysis and practices in order to intensify the rapid feedback against a defect that may appear. unit testing layer TDD — Test Driven Development code coverage static analysis The ( , and ) is extremely important nowadays, with a large focus on API testing. Here we apply , and to give speed in the execution of microservice tests. We also need separate test environment servers, where this can be the closest to a production environment. service layer component integration API mocks stubs fakes The (User Interface) layer is also important, especially from a mobile testing perspective where, when a customer encounters an error in an app, it usually removes it. The most important techniques here are automated testing in UI and . In the web part, we need browsers to execute the same test in different ones (IE, Chrome, Firefox, Safari). We need the same for : iOS and Android devices to ensure the compatibility of our app on these two platforms. UI Visual Regression Testing mobile automation testing The , created by and widely disseminated by Lisa Crispin and Janet Gregory in his book are some practices that can be applied during the activity-focused development of the test. The quadrant is a guide: it is not necessary to perform all the existing practices in it, you can choose one or more depending on your context. Agile Testing Quadrant Brian Marick “ Agile Testing — A Practical Guide for Testers and Agile Teams ” Continuous Delivery and Testing Pipeline There is no way to talk about without talking about (CD) … without it, we could not even talk about the DevOps culture. DevOps Continuous Delivery In Continuous Delivery, one of the foundations is the where we must test all the stages of our development (pipeline) with an initial recommendation applied to unit tests and automated acceptance. Continuous Testing Continuous Delivery enables joint roles between Development, QA and Operation. An example of evidence-focused collaboration for these roles is: Development + QA: Build, Deploy and Test automation at various levels QA + Operations: Test Automation and Continuous Feedback through test executions, as well as sanity test executions Operations + Development: Automated provisioning of machines/ containers required for testing at any level. Now we continue with the pipeline focused on tests, which can be applied in whole or in parts, being: Unit Test and Integration Test We can create mocks/fakes/stubs to remove the dependencies and acellerate the test executions ServiceTest: on service layers (SOAP, REST) : small execution subset to guarantee that all API’s are working (at least return status different from HTTP 404 or HTTP 500) Smoke : a collection of agreements (tests) between a client (consumer) and an Contract API : tests that want to guarantee the operation against different business rules (happy path, sad path and alternative flows) Functional : evaluate the system’s compliance with the business requirements and assess whether it is acceptable for delivery Acceptance Acceptance: acceptance testing Tests that focus on the user perspective and knowing as end-to-end testing (e2e). Important to simulate the user journey on the application. : main test suite what will guarantee your business running Smoke Functional: functional testing Tests that guarantee the operation against different business rules (happy path, sad/negative path and alternative flows) Smoke: main test suites of a happy path, sad path and alternative flows Non-Functional tests From to (end of the pipeline) we have to worry about non-functional tests. Examples of tests are functional: performance, load, security, etc … Integration Functional Testing And it’s extremely necessary to create an entire automated test architecture to support the continuous, automated, and least-maintenance run possible with: screenshots to evidence the execution of each test, or evidence when an error occurs logs to analyse and see any error occurred reports to show up a feedback about the test execution data management for the sensitive data on a test script parameterize commonly changed data like URL's, endpoints, etc… Toolbox for Automated API, Web and Mobile tests In order to automate an API, a Web page, and a Mobile front-end, there are open source that will help you to quickly and easily build and run tests. tools Rest Assured https://github.com/rest-assured/rest-assured Tool for creating automated tests for an API (REST and XML). Uses an easily and understood DSL based on ( ). Gherkin Given-When-Then In the example below it is possible to see the API through a local endpoint (simulating a production environment) and a mock endpoint created with Java Spark. Creating a mock API by developing the API fixed data returns can give even greater speed in the execution and validation of the different aspects that secure the tests for microservices, especially about contract tests. Selenium WebDriver http://seleniumhq.org It is the best-known tool for automation of a web page. It also has an easy DSL and is based on four steps for automation: Navigation: actions like access a web page, forward, back and refresh Interrogation: ways to find and web element like by id, name, cssSelectors and other locators Manipulation: a way to interact with an element like click, fill (sendKeys), clear and get text Synchronisation: ways to wait for some asynchronous actions, like an element that appears after some seconds It is a and performs actions in web browsers simulating a real browser. For this to be possible it is necessary to use the . W3C standard browsers drivers Appium http://appium.io It is an open source tool with the same Selenium DSL, but for automation in native or hybrid mobile device apps for iOS or Android. It supports execution on emulators, real device or test lab (cloud), and, in conjunction with Selenium Grid, gives the possibility of creating an internal device grid. Applied Pipeline and GitHub Repo The code for all projects can be found in the repository: _test-automation-javaone-2017 - An complete example of a pipeline focusing on API and UI (mobile and web) tests._github.com eliasnogueira/test-automation-javaone-2017 There are test suites for each pipeline step.