How to Efficiently Increase Unit Test Coverage in Java

Diffblue HQ
2 min readAug 16, 2019

--

Get higher code coverage faster and more easily. Photo by Hatham on Unsplash.

A lot of engineering managers dismiss this question because they know the answer: either have your team write more tests in between new development projects, or outsource the test writing. Both have pros, but both come with high costs, so when neither of these manual options is practical, engineering departments have to carry on with lower-than-ideal coverage.

Writing more tests is time-intensive and usually a tradeoff with new development. Outsourcing can be a solution in an emergency, but the price tag and time delay are both high: you still have to wait for the tests to be written, and in the meantime, the development team will be actively adding new code to your organization’s software.

Until recently, these were the only choices, because unit tests could only be created by a developer who devoted their time to writing them. However, with the introduction of a new AI-powered tool that can write code, tech managers have another option open to them.

Higher Code Coverage, Faster

Diffblue Cover was developed specifically to solve the problem of how to write a huge quantity of unit tests for large legacy codebases, without dedicating developer time to this momentous task. Diffblue Cover will analyze Java codebases and create an entire test suite for an application overnight.

How does it work?

The mathematical reasoning and learning engine powering the AI in Diffblue Cover builds a representation of a codebase and captures its behavior. It then uses deductive reasoning to create unit tests, which can also serve as documentation for legacy code.

The unit tests will track whether modifications to the code change its behavior; if a test fails after new code is added, the developer can see what might have caused that issue and resolve it earlier in the software development lifecycle, rather than letting your customers find the bug.

Developers can review the tests with ease and add new code with confidence and catch any regressions more quickly. The result is a robust legacy codebase that can hold up to modern needs and new development.

How can I try it?

For enterprise users, schedule a demo with our team to see how Diffblue Cover works and where it can fit into your software development lifecycle.

--

--

Diffblue HQ
Diffblue HQ

Written by Diffblue HQ

Diffblue Cover autonomous AI-powered Java unit test suite generation & maintenance at scale. | We’re making developers wildly more productive with AI for Code