Skip to main content

Why Automation and Testing Are Key to Smooth DevOps and CI/CD Pipelines

Anna Marrah from Midrange Dynamics North America explains why IBM i shops should consider the benefits of faster software delivery

TechChannel Application Development

The terms DevOps and CI/CD (Continuous Integration/Continuous Delivery) have become ubiquitous in recent years, and there are extremely good reasons for this. Companies that hone the use of CI/CD pipelines to become high performers improve their software delivery processes drastically.

According to “Accelerate: The Science of Lean Software and DevOps: Building and Scaling High Performing Technology Organizations,” those organizations that have adopted DevOps methodology have been shown to:

  • Deploy code up to 46 times faster
  • Recover from downtime 170 times faster
  • Have a lead time from commit to deploy that is 440 times faster than lower performing companies

These numbers translate into major business value.

When development and deployment are this fast, though, many worry that software quality will be diminished. This concern can cause companies to steer clear of DevOps methodologies.

However, this fear stems from not understanding how DevOps and CI/CD pipelines really work. When implemented properly, there should be no tradeoff between speed and software quality. How is this managed? Automated testing throughout the software development lifecycle (SDLC) is the solution.

Why SDLC Ensures Software Quality

SDLC provides many benefits for organizations.

Testing Ensures Software Quality

In DevOps, testing happens throughout the development process. This helps identify and fix defects early in the development cycle, preventing expensive issues in production by ensuring that quality and performance standards are met.

Automation Ensures Speed

Automation is the key feature of DevOps that increases speed and efficiency in the software delivery pipeline. When automated testing is built into the DevOps cycle, it enables teams to execute tests quickly and repeat them as needed for fast feedback on code changes. Testing automation can be integrated into a CI/CD pipeline seamlessly, promoting a reliable and streamlined release process while ensuring quality software in production.

Other Benefits in the Software Development Life Cycle

Together, automation and testing streamline the CI/CD pipeline and drive development toward faster speeds without the risk of lower quality. But as it turns out, automated testing brings numerous other benefits to an organization.

Time savings: Detecting problems earlier in the software development cycle results in quantifiable time savings. Developers can fix defects earlier and spend less time problem-solving and firefighting later.

Enable refactoring and iterative development: This benefit is huge for developers working on IBM i because, let’s face it, much of code in our business applications could benefit from updating. Refactoring our code helps improve readability for incoming programmers, simplifies unnecessary complexities, enhances maintainability and optimizes performance. It also supports evolutionary design while still ensuring consistency and compliance. These are all things we need within the IBM i environment as we work to modernize our code and bring fresh IT professionals into our industry.

DevOps and automated testing ensure developers can refactor with confidence, without fear of code regressions. When unit tests are in place, developers can modify code while ensuring that functionality remains intact. This enables more agile and iterative development, which in turn allows IBM i developers to improve their application codebase incrementally and respond more quickly to changing business requirements.

Unit Testing: A Great Place to Start

Many different testing techniques can be automated to help ensure software quality. One that we have been hearing more about recently is unit testing.

Unit tests are a great place to begin implementing test automation in your software development cycle. With this software testing technique, individual units or components of an application are tested in isolation from the rest of the system. This validates each unit of the software to ensure it performs as expected and to identify any defects in the code. As part of this process, quality gates with pass/fail results ensure that unit test results are within parameters set by the developer or the business.

The major advantages of unit testing are that it doesn’t require another resource and testing occurs within minutes or hours of the actual code modification. This helps create a robust product that performs well across features and functions.

8 Steps for Getting Started With Test Automation

If you are looking to implement unit test automation, start with these eight simple steps.

  1. Choose a testing framework. You will want to find a testing framework that aligns with your IT process, development environment, programming language and overall technology stack. Finding a framework with strong community support and documentation will help ensure your team can find resources to leverage best practices and resolve issues.
  2. Write unit test cases. Develop unit test cases that cover various scenarios, edge cases and expected behaviors. Incorporate assertions into the test cases to validate that the unit behaves as intended during testing. You will also need to create a subset of reusable and maintainable test code. This ensures that tests are easy to understand, update and expand as the application evolves. You can either write this code yourself or use a software tool to generate, obfuscate and maintain testing code.
  3. Use test doubles and mocking. Using mock objects, stubs and other test doubles allows you to isolate the unit under test from its dependencies and simulate the behavior of external components. You will also want to ensure that the unit you are testing is the sole focus of the test without unnecessary external dependencies. This speeds up the test and reduces complexity. Configuring mock objects to enhance your tests with predefined responses or simulated dependency behaviors is also a good idea because it enables a more comprehensive testing of edge cases within a controlled environment.
  4. Integrate tests into the build process. We are now at the stage when we can integrate the test into our CI/CD pipeline. This integration provides rapid feedback on code changes, allowing teams to respond to issues and correct them early in the development cycle. As you work to integrate the tests, you will incorporate them as part of the build verification process. This will establish a successful test execution to be a trigger indicating that the code has met functional requirements and is ready for the next stage of the pipeline. This is where quality comes into play, and it is an excellent stage of the process to leverage CI tools to create an immediate feedback loop. Tools such as Jenkins and GitLab CI and other third-party tools can be leveraged to trigger automated tests and deliver immediate feedback on build status. This feedback loop accelerates the development pace and enhances overall software quality.
  5. Run tests automatically. Beyond integrating testing that you can manually run in the CI/CD pipeline, you can automate tests to execute at predefined intervals or upon specific triggers, leveraging the benefits of automation mentioned earlier. You can run parallel tests across multiple environments or configurations to optimize your time. Cloud-based testing tools can also be utilized for scalability and flexibility in running automated tests across diverse environments.
  6. Collect and analyze test results. Tests are only as helpful as the data you have at the end of them. Reporting should include information beyond pass/fail statuses, detailing error messages and performance metrics as well. Interactive reporting tools that highlight trends and test coverage gaps can be used to support data-driven decision-making.
  7. Monitor code coverage. Measuring code coverage metrics assesses the effectiveness of automated tests in verifying code functionality. Aim for adequate test coverage to minimize the risk of undetected defects and enhance code reliability.
  8. Refactor and maintain tests. Maintaining test code is important for continuity and the reliability of your test results. Tools are available to help keep your test code clean and aligned with improvements and code changes in your environment.

Stability and Quality Are Both Possible

Harnessing the power and agility of DevOps and CI/CD pipelines does not mean that you lower the quality of your software. When you integrate testing and automation into your development cycle, you will see not only the increased speed associated with these methodologies but more stability and quality as well.