Have you been involved in a software project that ran over budget and blew past every deadline? Of course, you have – we all have. In fact, if you haven’t, you are a unicorn and I would like to hear from you.
Early stages in my software development career, I learned the importance of working backward from a deadline. If a project must be done by a certain date and testing will take a certain amount of time, then we can use that information to work backward and choose a due date for our project. Perfect, right?
Well, not quite. While building in time for manual testing reduced some stress in the final days of projects, there were still too many surprises.
Building in time for QA testing is great in theory but quickly falls apart in practice once the first bug or defect is identified.
How long will this defect take to fix? How much will it impact the timeline? Will new bugs be introduced? How will we ensure each fix is verified with time to fix anything we broke while we were fixing the first thing?
Ultimately, I was never able to find the correct amount of time to allocate for QA. Inevitably, rushed fixes were merged at the last minute; I learned to keep my calendar clear for a couple of weeks after big launches so that I could triage all of the issues we missed (or introduced) in our mad dashes to the finish.
The problem, at the end of the day, was not the time available for testing but rather the timing of the testing. I needed testing sooner and more often. I needed shift left testing.
IBM Instana Observability gives everyone across the enterprise user-friendly access to the data they want with the context they need to deliver rapid issue prevention and remediation.
Subscribe to the IBM newsletter
Get real-time visibility using shift-left testing with IBM Instana
If we imagine our software development process as a timeline flowing from left to right, then “shift left testing” becomes somewhat self-explanatory. Simply put, it is the practice of testing earlier stages and more often in the development life cycle.
Shift-Left Testing is an approach in software development that emphasizes moving testing activities earlier in the development process to improve software quality, test coverage, and time to market. By involving team members, including testers, developers, and stakeholders, in the testing strategy, and integrating testing for both existing and new features, organizations can ensure a high-quality codebase, continuous feedback, and faster time to market.
The V-model is a useful way to conceptualize software development cycles. If we take the traditional waterfall flow and “flip” the Y-axis at the implementation phase, we get the V-model.
A development cycle begins with high-level requirements. These requirements are narrowed down with each successive step down the “V” until we reach the code-level implementation itself. We then verify the implementation, starting with the most granular unit tests and working our way up the “V” to more abstract user acceptance testing.
In a waterfall process, the entire project is made up of a single “V.” As an industry, we have learned that when you leave all of your validation to the very end of a complex project, you are basically setting yourself up to fail.
In an iterative process, we can think of each sprint or iteration as a smaller “V.” We have theoretically achieved our goals of shift left: testing sooner and more often. Problem solved, right? Well… not quite.
You may have noticed that there are two labels on the feedback channel built into the V-model: verification and validation. These are both important.
We need to validate that our user requirements actually solve the problems we set out to solve. We also need to verify that our implementation matches the specifications we get from those user requirements.
Automated testing can be applied to both validations and verifications. BDD (Behavior Driven Design) has led to the creation of technologies such as Cucumber that can automate some parts of the validation process. For the purposes of this article, we will focus on automated testing for verification.
Unit tests verify the functionality of a specific module within a larger application. The module is tested in isolation, and any communication with other external processes is simulated or mocked. Unit testing and TDD represent the first development phase in shift left testing.
Integration tests attempt to verify the overall functionality of a service or application, including side effects. This is an anti-pattern for reasons we will discuss later.
API tests verify the external endpoints of a single service. The scope of API tests is similar to the scope of integration tests; However, in an SOA or Microservices context, we can think of API tests as the new unit tests.
UI tests verify the complete functionality of an application from the user interface layer. Tools like Selenium make automated UI testing widely accessible.
Shift left isn’t just about automation. Another way to test earlier and more often is to make sure that your QA specialists are involved in every step of your process, beginning with discovery and requirements gathering. Test engineers can do better when they have a greater understanding of the overall implementation, and their insights can help make the architecture more transparent and resilient.
When we think of testing “sooner and more often” a certain word comes to mind: continuous. Many (most) software development teams are practicing some form of continuous integration and continuous delivery. Continuous testing is a vital feedback loop in this DevOps cycle.
If we think of TDD as “Shift left for monoliths,” then continuous testing is “shift left for distributed architectures.”
TDD had us focus on unit testing. For continuous testing we should focus on API and contract tests. API tests have a number of benefits:
API tests can prevent one of the most common ways to introduce errors in a microservice application: changing a dependency out of sync with its upstream or downstream services.
API tests can be owned by the same team that owns the tested service.
API tests avoid the brittleness of testing side effects and implementation details.
Ideally, these API tests will be run continuously against both production and pre-production environments. Contract testing tools can help automate this process, but that requires additional infrastructure.
What if we could use continuous API testing built into our observability tool? The upcoming synthetic API testing feature from Instana will let you continuously run API tests against all of your environments with minimal effort.
Shift Left involves moving the testing activities closer to the beginning of the software development lifecycle, enabling faster feedback, and reducing the time and effort required for bug fixing. Here are some best practices for Shift-Left Testing in Agile:
Early involvement: Testing activities should begin as early as possible in the development process. Testers should be involved from the requirements gathering phase to understand the project scope, objectives, and user expectations.
Collaboration and communication: Foster close collaboration and communication between developers, testers, and other stakeholders. Encourage daily stand-up meetings, sprint planning sessions, and regular retrospectives to ensure shared understanding and alignment.
Test automation: Invest in test automation to enable frequent and efficient testing. Automated tests should be created alongside the development process and integrated into the continuous integration and deployment pipelines. This helps in detecting defects early, reducing regression issues, and speeding up feedback cycles.
Test-driven development (TDD): Encourage the practice of TDD, where developers write test cases before writing the actual code. This shift left testing approach helps in defining the desired behavior and expected outcomes upfront, leading to more robust and testable code.
Continuous integration and continuous delivery (CI/CD): Implement CI/CD pipelines to automate the build, test, and deployment processes. This ensures that each code change is thoroughly tested and deployed to production environments quickly and frequently, reducing the risk of integration issues.
Shift-Left security testing: Consider integrating security testing practices early in the development process. Conduct security code reviews, static code analysis, and security-focused testing to identify vulnerabilities and address them proactively.
Exploratory testing: Alongside automated tests, encourage exploratory testing to explore the application from a user's perspective. Skilled testers can identify potential usability issues, edge cases, and scenarios that automated tests might miss.
Performance testing: Perform performance testing early to identify potential bottlenecks and scalability issues. This helps in optimizing the application's performance and ensuring it meets the required performance criteria.
Test environments and data: Provision test environments that closely resemble production environments to ensure realistic software testing. Also, ensure that sufficient and representative test data is available to simulate real-world scenarios.
Continuous learning and improvement: Foster a culture of continuous learning and improvement. Encourage regular retrospectives to reflect on testing processes, identify bottlenecks, and implement changes to enhance the effectiveness of Shift-Left Testing.
By following these best practices, Agile teams can achieve better collaboration, faster feedback, and higher quality software products through Shift-Left Testing.
The shorter feedback loops built into shift left processes empower us in several ways. Defects can be found faster, fixes can be applied more efficiently, and lessons learned in one iteration can be applied in the next, to name a few.
Whatever project management methodology or release cadence your team has, you can benefit from the shorter verification feedback loops from shift left testing.
A defect found by an automated unit test on a developer’s local machine is orders of magnitude cheaper to identify and fix than a defect that has made it all the way to a customer-facing environment.
When done properly, automated testing and CI can provide the confidence that software engineers need to deploy often — even on Fridays. Finding defects sooner means fewer panicked all-hands moments. Since releases are so painless, fixing the few errors that do make it through is faster and easier too.
Just as more accessible software is usually easier to use for all of us, more testable software can be easier to reason about and maintain. Thinking about testing early can lead to better separation of concern and a more resilient overall architecture.
Improving the customer experience is our ultimate goal. Shift left can eliminate some incidents that end users might experience and reduce the impact of other incidents. We can use observability to complete this feedback loop and improve our overall software health.
With powerful automation tools at our disposal, it can be tempting to implement every kind of testing on every line of code. This is a dangerous path.
Testing side effects — did that record actually get saved to the database? — is an attractive idea. But testing implementation details is an anti-pattern because these types of tests are extremely brittle. They might need to be changed every time your application is changed. The user interface is also an implementation detail, so UI tests land in this same boat.
Verification tests just care about the “what,” not the “how” or the “why.” Ideally, the user requirements have been designed to validate “why.” To answer “how” we can rely on a more powerful automation in the form of an observability platform.
Shift right testing is the practice of testing later in the development process, usually in production environments. While it may seem strange, shift left and shift right testing are complimentary.
Shift right testing allows us to identify production issues before our customers do. The shorter feedback loops from shift left testing give us the ability to respond to and remediate these production issues rapidly.
Synthetic API testing as a part of your observability platform is the perfect way to combine the benefits of shift left and shift right practices.
Observability provides deep visibility into modern distributed applications for faster, automated problem identification and resolution
Continuous testing plays a crucial role in accelerating software development, improving code quality, and avoiding costly bottlenecks.
DevOps speeds delivery of higher-quality software by combining and automating the work of software development and IT operations teams
Learn everything you need to know about synthetic monitoring including what it is, how to use it, the challenges and more
The application of technology, programs, robotics or processes to achieve outcomes with minimal human input
Predict and prevent performance issues before they impact your business with application performance management
IBM Instana provides real-time observability that everyone—and anyone—can use. It delivers quick-time-to-value while ensuring your observability strategy can keep up with the dynamic complexity of today’s environments, and tomorrow’s. From mobile to mainframe, Instana supports over 250 technologies and growing.