google/guava · error · IllegalStateException
Call named() before createTestSuite().
Error message
Call named() before createTestSuite().
What it means
Thrown by checkCanCreate() when createTestSuite() is called but the suite name (set via named(...)) is still null. The name is used as the JUnit TestSuite display name and in log output, so the builder treats an unnamed suite as a misconfiguration rather than defaulting it.
Source
Thrown at android/guava-testlib/src/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilder.java:212
for (@SuppressWarnings("rawtypes") // class literals
Class<? extends AbstractTester> testerClass : testers) {
@SuppressWarnings("unchecked") // getting rid of the raw type, for better or for worse
TestSuite testerSuite =
makeSuiteForTesterClass((Class<? extends AbstractTester<?>>) testerClass);
if (testerSuite.countTestCases() > 0) {
suite.addTest(testerSuite);
}
}
return suite;
}
/** Throw {@link IllegalStateException} if {@link #createTestSuite()} can't be called yet. */
protected void checkCanCreate() {
if (subjectGenerator == null) {
throw new IllegalStateException("Call using() before createTestSuite().");
}
if (name == null) {
throw new IllegalStateException("Call named() before createTestSuite().");
}
if (features == null) {
throw new IllegalStateException("Call withFeatures() before createTestSuite().");
}
}
@SuppressWarnings("rawtypes") // class literals
protected abstract List<Class<? extends AbstractTester>> getTesters();
private boolean matches(Test test) {
Method method;
try {
method = extractMethod(test);
} catch (IllegalArgumentException e) {
logger.finer(Platform.format("%s: including by default: %s", test, e.getMessage()));
return true;
}
if (suppressedTests.contains(method)) {View on GitHub (pinned to 94f39958ba)
Solutions
- Add .named("<human-readable suite name>") to the builder chain before createTestSuite().
- Keep the canonical chain order using(...) -> named(...) -> withFeatures(...) -> createTestSuite().
- If you refactored name into a constant/variable, confirm it is non-null at call time.
Example fix
// before
TestSuite suite = ListTestSuiteBuilder.using(gen)
.withFeatures(ListFeature.GENERAL_PURPOSE)
.createTestSuite();
// after
TestSuite suite = ListTestSuiteBuilder.using(gen)
.named("MyList")
.withFeatures(ListFeature.GENERAL_PURPOSE)
.createTestSuite(); Defensive patterns
Strategy: validation
Validate before calling
java.util.Objects.requireNonNull(suiteName, "named() requires a non-null name"); TestSuite suite = ListTestSuiteBuilder.using(gen).named(suiteName).withFeatures(F).createTestSuite();
Prevention
- Treat the builder chain as a checklist; never skip named(...).
- Store suite names in constants to avoid accidental null/deletion.
When it happens
Trigger: A builder chain that calls using(...) and withFeatures(...) but omits named("...") before createTestSuite(). The guard at line 211 sees name == null and throws.
Common situations: Reordering a fluent builder chain and losing the named(...) call; renaming a suite variable and accidentally deleting the named() step; assuming createTestSuite() derives a name from the generator class (it does not).
Related errors
- Call using() before createTestSuite().
- Call withFeatures() before createTestSuite().
- %s: no CollectionSizes specified (check the argument to Feat
- A compound CollectionSize doesn't specify a number of elemen
- unable to extract method from test: not a TestCase.
AI-assisted analysis of google/guava@94f39958ba (2026-08-13).
Data as JSON: /api/errors/da272ff34c34a5d2.
Report an issue: GitHub.