Testing is a very important aspect of the software delivery process. A couple of testing types can be easily automated and get integrated with the build and release pipelines in order to assure the quality of the delivered software projects or products.
In this chapter, we are going to look at the types of testing that can be automated and the features and components that we can use to effectively run test automations with pipelines.
Lesson 12.01: Running Unit Tests with Pipelines
It is important to validate the code of your application with unit tests to ensure the code is working as expected. Unit tests are implemented to test the code that is written by the developers using the test-driven development approaches (TDD) and behavioral driven development (BDD).
Using a Visual Studio Test task, you can execute multiple types of tests developed with test frameworks such as MSTest, xUnit, NUnit, etc. The task allows you to distribute your test across multiple agents to run them efficiently, while using a multiple agents configuration in the agent job.
In this lesson, we discussed how we can utilize tasks available for pipelines to set up unit test execution with build pipelines.
Lesson 12.02: Running Functional Tests with Pipelines
Integration and functional tests are used to test deployed applications. They might be implemented as API-level testing or User Interface testing using different test frameworks. Selenium is one of the main test frameworks widely used with .Net and other languages. There are other test frameworks such as Cypress, which is also facilitating scenario-based functional UI test implementation.
The implemented automated functional testing to test an application should be executed after a deployment to a given target to make sure the target application is working as expected. Automation and running the automated functional tests with deployment pipelines enable teams to run most of their tests, for each release, so that higher quality in delivered applications can be achieved.
A functional test based on Selenium requires you to run the agent in interactive mode to execute the testing. We talked about setting up agents in Chapter 3 of this book. However, Cypress framework UI tests can be executed with non-interactive agents as well.
Then you can use the VS Test task to execute the tests written with Selenium using C#. If you have developed the tests in Java, you can use Maven tasks to execute the tests in the release pipelines.
We discussed the usage of release pipelines to execute functional tests in this lesson.
Summary
In this chapter, we discussed the usage of unit tests and functional test execution to ensure quality of the delivered applications.
We talked about several important facts in regard to Azure pipelines in this book. We have gone through why we need to implement continuous integration and delivery with the introductory chapter. Then we explored how the agent pools and agents and even the deployment setup. Next, we discussed classic build pipelines in detail in the next couple of chapters. The YAML pipelines were also discussed to enable you to understand the usage of pipelines as code. In addition to that, we discussed release pipelines usage and implementation and usage of test execution in release and build pipelines. Overall, the book has given you essential insights into implementing and using Azure pipelines, to enable you to deploy software applications with a rapid cadence while not compromising the quality of the applications delivered.