{"record":{"id":"da272ff34c34a5d2","repo":"google/guava","slug":"call-named-before-createtestsuite","errorCode":null,"errorMessage":"Call named() before createTestSuite().","messagePattern":"Call named\\(\\) before createTestSuite\\(\\)\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"android/guava-testlib/src/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilder.java","lineNumber":212,"sourceCode":"    for (@SuppressWarnings(\"rawtypes\") // class literals\n    Class<? extends AbstractTester> testerClass : testers) {\n      @SuppressWarnings(\"unchecked\") // getting rid of the raw type, for better or for worse\n      TestSuite testerSuite =\n          makeSuiteForTesterClass((Class<? extends AbstractTester<?>>) testerClass);\n      if (testerSuite.countTestCases() > 0) {\n        suite.addTest(testerSuite);\n      }\n    }\n    return suite;\n  }\n\n  /** Throw {@link IllegalStateException} if {@link #createTestSuite()} can't be called yet. */\n  protected void checkCanCreate() {\n    if (subjectGenerator == null) {\n      throw new IllegalStateException(\"Call using() before createTestSuite().\");\n    }\n    if (name == null) {\n      throw new IllegalStateException(\"Call named() before createTestSuite().\");\n    }\n    if (features == null) {\n      throw new IllegalStateException(\"Call withFeatures() before createTestSuite().\");\n    }\n  }\n\n  @SuppressWarnings(\"rawtypes\") // class literals\n  protected abstract List<Class<? extends AbstractTester>> getTesters();\n\n  private boolean matches(Test test) {\n    Method method;\n    try {\n      method = extractMethod(test);\n    } catch (IllegalArgumentException e) {\n      logger.finer(Platform.format(\"%s: including by default: %s\", test, e.getMessage()));\n      return true;\n    }\n    if (suppressedTests.contains(method)) {","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/google/guava/blob/94f39958baf7ad51ddf9c70e406ed6b188194daa/android/guava-testlib/src/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilder.java#L194-L230","documentation":"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.","triggerScenarios":"A builder chain that calls using(...) and withFeatures(...) but omits named(\"...\") before createTestSuite(). The guard at line 211 sees name == null and throws.","commonSituations":"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).","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."],"exampleFix":"// before\nTestSuite suite = ListTestSuiteBuilder.using(gen)\n    .withFeatures(ListFeature.GENERAL_PURPOSE)\n    .createTestSuite();\n\n// after\nTestSuite suite = ListTestSuiteBuilder.using(gen)\n    .named(\"MyList\")\n    .withFeatures(ListFeature.GENERAL_PURPOSE)\n    .createTestSuite();","handlingStrategy":"validation","validationCode":"java.util.Objects.requireNonNull(suiteName, \"named() requires a non-null name\");\nTestSuite suite = ListTestSuiteBuilder.using(gen).named(suiteName).withFeatures(F).createTestSuite();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the builder chain as a checklist; never skip named(...).","Store suite names in constants to avoid accidental null/deletion."],"tags":["guava-testlib","test-setup","illegal-state","builder"],"backgroundTag":null,"analyzedSha":"94f39958baf7ad51ddf9c70e406ed6b188194daa","analyzedAt":"2026-08-13T22:50:30.265Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}