8 Effective Solutions to Reduce Automation Test Case Execution Time on the CI CD Pipeline
As an SDET and DevOps Engineer, I often encounter the issue of long-running automation test cases on the CI CD Pipeline. This can be frustrating, as it slows down the testing process and can delay the release of new features. However, there are several solutions that can help to optimize your automation test cases and reduce the time it takes to run them. In this article, I will discuss some of the most effective solutions that I have found to be helpful.
1. Optimize your automation test cases
The first step is old school but effective, look for ways to optimize them. This can include reducing the number of unnecessary steps, making use of parallelization(must), and prioritizing critical tests.
Informative link: https://www.toolsqa.com/testng/testng-parallel-execution/
2. Follow the Test pyramid
Following the test pyramid can help you to understand the correct approach to Test Automation Suite development. Develop more test cases as Unit Tests, then API Tests, and finally API/UI Combination for E2E Testing. As Unit Tests and APIs are faster to run, you can reduce the overall execution time of your test suite.
Informative link: https://martinfowler.com/articles/practical-test-pyramid.html
3. Run the right suite
Not all test cases need to be executed every time.
Eg. If Module A is deployed why do you wish to run Module B Tests or regression? You can live with the Module A test case and the module which is getting impacted by the code drop.
You can achieve this by passing the Module name as custom properties in Maven/Gradle command via Jenkins and configuring Groups based on Module/env.
mvn test -DmoduleName=ModuleName -Denv=it
4. Distribute the Test Suite in different schedules
All Test cases are not important to run every day. Use the Jenkins Parameterized Scheduler Plugin to run test cases for different modules/envs at different times of the day. This can help to ensure that your tests are executed at times when the resources are available, and can reduce the overall execution time.
Informative link: LinkedIn Post-Parameterized-scheduler-plugin
5. Use caching
Caching involves storing the results of previously executed tests and reusing them when possible. Jenkins has a number of plugins that can help with caching, such as the Jenkins Caching Plugin or the creation of docker images having dependencies already downloaded offline. By using caching, you can avoid unnecessary work and reduce the overall execution time of your test suite.
Informative link: https://www.baeldung.com/ops/docker-cache-maven-dependencies
6. Increase the resources allocated to Jenkins
If you’re running Jenkins on a server with limited resources, consider increasing the resources allocated to it. This could include increasing the amount of memory or CPU cores available to Jenkins. By increasing the resources, you can ensure that Jenkins has the necessary resources to execute your test suite in a timely manner.
7. Use parallel stages in Jenkins
Using parallel stages in Jenkins can help you to run more test cases in the same amount of time. By breaking up your test suite into smaller, parallel stages, you can reduce the overall execution time and speed up the testing process.
To advance you can use Dynamic parallel stages which can create stages on runtime demand, refer below.
Informative link: LinkedIn Post: Dynamic Stage Creation
8. Use a cloud-based solution
Consider using a cloud-based solution, such as AWS or Azure, to run your tests and create Selenium Grid. This can provide you with access to additional resources and make it easier to scale your testing as needed.
Informative link: https://aws.amazon.com/blogs/opensource/run-selenium-tests-at-scale-using-aws-fargate/
In conclusion, optimizing your automation test cases is essential for reducing the time it takes to run them on the CI CD Pipeline. By following the solutions discussed in this article, you can reduce the overall execution time of your test suite and speed up the testing process. This will help you to deliver new features to your users more quickly and improve the overall quality of your software.
Wish to discuss more comment below / connect with me on
- LinkendIn: https://www.linkedin.com/in/shikhar-sri/
- Topmate: https://lnkd.in/gnP6Jz9F
- Medium: https://lnkd.in/g8pN3-JR