Java code testing: These open source tools and rethinking the process can reduce the burden for developers

Commentary: Developers do a lot of testing, a new survey finds. Are there ways to improve testing while reducing the time it takes?

Software developer freelancer woman working at night

Image: Getty Images/iStockphoto, monstArrr_

The open source Spring framework and Spring Boot, both created by Rod Johnson, are far and away the most popular tools for enterprise Java developers, according to a just-released independent survey of 450 developers from small and large organizations. Eighty-six percent of respondents rely on Spring/Boot according to the survey, sponsored by Diffblue, providers of AI-automated Java unit testing software. That's far more than the 60% found by Spring vendor Pivotal's own survey of 1,000 developers last year.

This latest survey, conducted independently of Pivotal and Diffblue by Vanson Bourne, a U.K. firm, collected answers anonymously from panels of participants (150 in the U.K. and 300 in the U.S.). The 15-question survey included a mixture of Likert scales, multiple choice and open-ended questions. The biggest surprise? The copious quantity of time developers spend on testing. Not writing new applications. Testing. Is this a bad thing?

Going back to (testing) school

A whopping 96% of Spring users say the Spring/Boot tooling helps them be better Java developers. That's perhaps not surprising, though maybe the percentage is. More surprising is that 8% of the respondents use no framework at all. 

But the biggest surprise, and arguably not a good one, is how much time developers spend on mind-numbing test writing. Yes, the survey did find that testing is easier when done with Spring, but up to half of a developer's time goes into test writing. That's time not spent adding features, modernizing applications or doing the things developers actually love to do. 

So is this time wasted? Not at all. But perhaps time spent testing could be minimized. That's the goal.

SEE: 10 ways to prevent developer burnout (free PDF) (TechRepublic)

The main reason most production Java developers rely on Spring is that it saves them time (58% in writing code). The second most popular benefit of Spring is making it easier to write unit tests. The survey found that the three leading ("very useful") Java testing tools were Junit (44%), TestNG (40%) and Diffblue Cover (39%).

"We found that not only is Spring incredibly well liked, but developers feel they write better code, achieve higher maintainability, and that it makes unit testing easier," said Mathew Lodge, CEO of Diffblue. "The survey shows that developers using Spring simply test more. We think it's a compelling example of how good tooling can help organizations adopt a better way of working."

Testing as more than an afterthought

A lead product engineer in a large Java shop at a major financial services company recently told me why testing is so important in his enterprise. "We're essentially trying to build fully automated, immutable services," he said. For him, testing is at the center of his organization's strategy (more than 3,500 developers in the company running more than 150 bespoke applications) to modernize and simplify their software stack.

He said: "Our strategy moving forward is to be more focused on serverless and microservices. Our whole data strategy is morphing as well. We want to develop technology very quickly, build advanced sophisticated products, and be able to evolve those. But we want to do it in a fashion that is low friction and very simple for the developers to implement. We're not trying to dumb down their jobs. We're trying to remove the need to have separate ops teams. We're trying to blend the notion of dev and QA."

To decouple, the organization needs to understand its own code better, he said. Unit tests help them do that.

"We're trying to reduce the bespoke customization for applications where it makes sense," he said. "Generating volume around data is what we do."

His team is breaking down many of their older applications one piece at a time. "Some of our older applications, we don't understand very well," he said. "We have no unit test base, or very, very limited unit test bases." So his team is extracting features that can be implemented as functions on their own internal serverless platform. A function might expose a web page or maybe it's just a data service. His team needs reliable unit tests to go in and extract the useful bits and perhaps modify the code. Unit tests record the state of the program, the way it works.

"How do I extract code from old systems and then surgically put them back together and have some confidence I'm not actually breaking anything?" he said. "Test first. Especially if we're leaving the code in production."

His ultimate goal is to retire many of the older applications that are expensive or difficult to maintain--or simply make them more configurable so that he can put the change upgrade extensions in the hands of users.

Improving the development workflow

What he really wants to create is a self-directed environment where users--product managers themselves, who know what is best for their business, not just developers--understand their products. Instead of having 10 or 20 or 30 "scrum teams" all pulled together across the company on some momentous effort to test and deploy a release, he wants teams to be able to work and release independently and not necessarily have to interact with the central development team.

"It's actually about the developer workflow," he said. "It's how we manage InfoSec, safe coding and all these different dimensions. We want to try to make life easier for developers so they can focus on what they do best."

He wants his engineering group to focus on roadmaps, technology engineering concerns and how the platform develops. "The main focus for the technology division this year is to leverage AI-powered tooling," he said. "We want to look for productivity gains. We want to reduce manual tasks so that we can focus on more high-value activities."

According to the survey, the good news is that Spring makes it much easier to write Java unit tests in the first place. While testability ranked fourth among the top benefits Spring users cited, the framework is designed to follow a standardized way of doing unit testing, with built-in mocking and ease of isolating the units under test and database tendencies. Adding AI to Spring, as Diffblue and others are now doing, could be just the right amount of magic to make testing easier for developers. That's critical, given just how much they continue to test.

Disclosure: I work for AWS, but the views expressed herein are mine.

Also see

By Matt Asay

Matt Asay is a veteran technology columnist who has written for CNET, ReadWrite, and other tech media. Asay has also held a variety of executive roles with leading mobile and big data software companies.