{"record":{"id":"c1df64b20a5613df","repo":"google/guava","slug":"s-no-collectionsizes-specified-check-the-argume","errorCode":null,"errorMessage":"%s: no CollectionSizes specified (check the argument to FeatureSpecificTestSuiteBuilder.withFeatures().)","messagePattern":"(.+?): no CollectionSizes specified \\(check the argument to FeatureSpecificTestSuiteBuilder\\.withFeatures\\(\\)\\.\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"android/guava-testlib/src/com/google/common/collect/testing/PerCollectionSizeTestSuiteBuilder.java","lineNumber":80,"sourceCode":"    // Copy this set, so we can modify it.\n    Set<Feature<?>> features = copyToSet(getFeatures());\n    @SuppressWarnings(\"rawtypes\") // class literals\n    List<Class<? extends AbstractTester>> testers = getTesters();\n\n    logger.fine(\" Testing: \" + name);\n\n    // Split out all the specified sizes.\n    Set<Feature<?>> sizesToTest = copyToSet(CollectionSize.values());\n    sizesToTest.retainAll(features);\n    features.removeAll(sizesToTest);\n\n    addImpliedFeatures(sizesToTest);\n    sizesToTest.retainAll(asList(CollectionSize.ZERO, CollectionSize.ONE, CollectionSize.SEVERAL));\n\n    logger.fine(\"   Sizes: \" + formatFeatureSet(sizesToTest));\n\n    if (sizesToTest.isEmpty()) {\n      throw new IllegalStateException(\n          name\n              + \": no CollectionSizes specified (check the argument to \"\n              + \"FeatureSpecificTestSuiteBuilder.withFeatures().)\");\n    }\n\n    TestSuite suite = new TestSuite(name);\n    for (Feature<?> collectionSize : sizesToTest) {\n      String oneSizeName =\n          Platform.format(\n              \"%s [collection size: %s]\", name, collectionSize.toString().toLowerCase());\n      OneSizeGenerator<T, E> oneSizeGenerator =\n          new OneSizeGenerator<>(getSubjectGenerator(), (CollectionSize) collectionSize);\n      Set<Feature<?>> oneSizeFeatures = copyToSet(features);\n      oneSizeFeatures.add(collectionSize);\n      Set<Method> oneSizeSuppressedTests = getSuppressedTests();\n\n      OneSizeTestSuiteBuilder<T, E> oneSizeBuilder =\n          new OneSizeTestSuiteBuilder<T, E>(testers)","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/google/guava/blob/94f39958baf7ad51ddf9c70e406ed6b188194daa/android/guava-testlib/src/com/google/common/collect/testing/PerCollectionSizeTestSuiteBuilder.java#L62-L98","documentation":"Thrown by PerCollectionSizeTestSuiteBuilder when, after intersecting the declared features with the known CollectionSize values (ZERO/ONE/SEVERAL), no sizes remain. The builder splits test suites by collection size, so zero sizes means it cannot create any size-specific child suite.","triggerScenarios":"Calling withFeatures(...) with feature sets that include no CollectionSize members (e.g. only CollectionFeature/MapFeature constants), or where all CollectionSize entries were suppressed/removed. sizesToTest is empty after the retainAll at line ~74.","commonSituations":"Passing only non-size features such as withFeatures(MapFeature.GENERAL_PURPOSE); copying a Map/List builder config but dropping CollectionSize.ANY; custom Feature enums that do not imply any CollectionSize.","solutions":["Add at least one CollectionSize to withFeatures(...), most commonly CollectionSize.ANY (which implies ZERO, ONE, SEVERAL).","If you intentionally want a single size, pass withFeatures(CollectionSize.ONE) explicitly.","Check that no prior .suppress(...) or feature-removal logic is stripping every CollectionSize."],"exampleFix":"// before\nTestSuite suite = MapTestSuiteBuilder.using(gen)\n    .named(\"MyMap\")\n    .withFeatures(MapFeature.GENERAL_PURPOSE)\n    .createTestSuite();\n\n// after\nTestSuite suite = MapTestSuiteBuilder.using(gen)\n    .named(\"MyMap\")\n    .withFeatures(MapFeature.GENERAL_PURPOSE, CollectionSize.ANY)\n    .createTestSuite();","handlingStrategy":"validation","validationCode":"Set<Feature<?>> feats = Set.of(MapFeature.GENERAL_PURPOSE);\nboolean hasSize = feats.stream().anyMatch(f -> f instanceof CollectionSize\n    || f.getImpliedFeatures().stream().anyMatch(i -> i instanceof CollectionSize));\nif (!hasSize) feats = new HashSet<>(feats); feats.add(CollectionSize.ANY);\nbuilder.withFeatures(feats);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["For any collection/map builder, always pass CollectionSize.ANY (or specific sizes) in withFeatures.","Wrap suite construction in a helper that asserts at least one CollectionSize is present."],"tags":["guava-testlib","test-setup","features","collection-size"],"backgroundTag":null,"analyzedSha":"94f39958baf7ad51ddf9c70e406ed6b188194daa","analyzedAt":"2026-08-13T22:50:30.265Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}