Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Guava library for Java has unit test cases automatically generated:

Guava has staggering numbers of unit tests: as of July 2012, the guava-tests package includes over 286,000 individual test cases. Most of these are automatically generated, not written by hand, but Guava's test coverage is extremely thorough, especially for

How they were generated? What techniques and technologies were used to design and generate them?

My guess

My first guess is they follow parametrized tests approach. The package has a lot of classes with "Generator" in their names -- making it look like a framework for tests generation. The package lists the features/constrains that a "collection" implementation (e.g., for a list, a set) should satisfy. So a test case parametrize what features a particular implementation should have.


My original question on Programmers SE got much attention from the community but no reasonable answer, so I'm trying to get it here. My motivation behind such a question is to learn more in general about techniques (parametrized tests, random tests, etc.) and technologies (code templates, etc.) used to automate test case generation.

share|improve this question
up vote 2 down vote accepted

(Also answered at the original question on

A large part of this mass of tests is for their collection implementations. They've written generic tests that exhaustively test the collection interfaces, and this generates a suite per implementation. See, for example, classes called CollectionAddAllTester, ListIndexOfTester.

This is all backed by a library called testlib, which ships as part of Guava. This is quite generic. It supports writing generic tests for any interface (not just collections). You can specify Features of possible implementations and test those (e.g. if your set is unmodifiable you expect a different outcome from set.add()), and when you run the tests you specify which features your implementation supports.

I wrote a post on how to write testlib generating suites for your own interfaces.

share|improve this answer
Thanks for correcting the link. – dzieciou Jan 25 '15 at 9:17

One possibility is the use of CodePro Analytix by Google which has a JUnit Test Case Generation feature.

share|improve this answer
Can you explain more how it works? – dzieciou Jun 13 '13 at 7:46
Its probably similar to how SoapUI can read a webservice WSDL and then it knows how to generate all the stubs for all the endpoint methods. I would guess CodePro Analytix must use Reflection to generate tests (or at least the stubs)? This is a total guess: stab in the dark. – djangofan Aug 15 '13 at 22:45
So it just generate stubs, correct? – dzieciou Aug 26 '13 at 19:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.