Continuous Delivery Through Smarter Unit Testing

Using machine learning, Launchable ranks unit tests for each code change and allows you to create a unique subset based on this ranking.

Key Takeaways

  • A unit test tests a single unit of code, as in the smallest piece of code that can be isolated in a system.

  • Unit tests are beneficial because they are typically fast tests with minimal setup needed to test. The speed is thanks to the test simplicity and the limited variables involved.

  • Unit testing offers an opportunity to speed up development cycles. Using machine learning, Launchable ranks unit tests for each code change and allows you to create a unique subset based on this ranking.

Different testing phases within the software development lifecycle encounter inefficiencies that can be a drain on cycle times. New testing solutions have emerged that eliminate testing bottlenecks so companies can focus even more resources on developing new features and shipping quality code faster. Unit testing is often considered the fastest test type, but there are two approaches to increasing the velocity of your unit tests. 

The Nature of Unit Testing

A unit test tests a single unit of code, as in the smallest piece of code that can be isolated in a system. Unit tests can be a function, subroutine, property or method. In the software testing pyramid, unit tests sit within the bottom, lowest and largest section. This is because unit tests are closest to the code. Focusing testing on a single function, unit tests are beneficial because they are typically a fast test with minimal setup needed to test. The speed is thanks to the test simplicity and the limited variables involved.

Because unit tests are tightly coupled with the software they test, the tooling you use to build your software, like Maven or Gradle, is also used to run your unit tests. By their nature, unit tests are easy to write and easy to run. But there are a few common scenarios where unit tests can become inefficient.

Speed Up Releases with Smarter Unit Testing 

The outcome of a unit test is binary: it passes if the program’s behavior is consistent with the recorded expectations, or it fails. The test itself is likely not a tax on developers as unit tests run relatively quickly. Developers often group a large number of unit tests (corresponding to a large number of program behaviors of interest), into test suites. Some teams have tens, hundreds, thousands, or more of unit tests running during development. This is where unit testing inefficiencies can bloat cycle times and tax resources. 

In the instance where developers have an application with a large number of unit tests, they can harness Launchable’s machine learning to intelligently select the critical tests to run for a change, cutting down on test execution time. If a developer commonly runs their test suite for 30 minutes four times a day, they have the opportunity to shift left their critical tests and find risks earlier while saving time by not running every test. At the end of the day, they could run one big test of their full suite. Unit tests can be parallelized easily as well using the Launchable CLI. You can divide a subset into equal chunks to be run in parallel

Additionally, when working with some languages (like C or C++) you need to build a test executable application in order to run unit tests. The time spent developing the test adds up: first building the test, running it, and then examining the results. Using Predictive Test Selection, teams can use Launchable to not only run fewer tests, but also build fewer test executables, saving lots of time.

Unit testing offers an opportunity to speed up development cycles. Using machine learning, Launchable ranks unit tests for each code change and allows you to create a unique subset based on this ranking. Run a fraction of your test suite while still maintaining high confidence that if a failure exists it will be found.

At Launchable, we’re working on making testing smarter, empowering developers to spend even more time building business differentiating application features and less on making sure that their software works.