Search in sources :

Example 1 with TesterRequirements

use of com.google.common.collect.testing.features.TesterRequirements in project guava by google.

the class FeatureSpecificTestSuiteBuilder method matches.

private boolean matches(Test test) {
    final 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)) {
        logger.finer(Platform.format("%s: excluding because it was explicitly suppressed.", test));
        return false;
    }
    final TesterRequirements requirements;
    try {
        requirements = FeatureUtil.getTesterRequirements(method);
    } catch (ConflictingRequirementsException e) {
        throw new RuntimeException(e);
    }
    if (!features.containsAll(requirements.getPresentFeatures())) {
        if (logger.isLoggable(FINER)) {
            Set<Feature<?>> missingFeatures = Helpers.copyToSet(requirements.getPresentFeatures());
            missingFeatures.removeAll(features);
            logger.finer(Platform.format("%s: skipping because these features are absent: %s", method, missingFeatures));
        }
        return false;
    }
    if (intersect(features, requirements.getAbsentFeatures())) {
        if (logger.isLoggable(FINER)) {
            Set<Feature<?>> unwantedFeatures = Helpers.copyToSet(requirements.getAbsentFeatures());
            unwantedFeatures.retainAll(features);
            logger.finer(Platform.format("%s: skipping because these features are present: %s", method, unwantedFeatures));
        }
        return false;
    }
    return true;
}
Also used : TesterRequirements(com.google.common.collect.testing.features.TesterRequirements) ConflictingRequirementsException(com.google.common.collect.testing.features.ConflictingRequirementsException) Method(java.lang.reflect.Method) Feature(com.google.common.collect.testing.features.Feature)

Example 2 with TesterRequirements

use of com.google.common.collect.testing.features.TesterRequirements in project guava by hceylan.

the class FeatureSpecificTestSuiteBuilder method matches.

private boolean matches(Test test) {
    final 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)) {
        logger.finer(Platform.format("%s: excluding because it was explicitly suppressed.", test));
        return false;
    }
    final TesterRequirements requirements;
    try {
        requirements = FeatureUtil.getTesterRequirements(method);
    } catch (ConflictingRequirementsException e) {
        throw new RuntimeException(e);
    }
    if (!features.containsAll(requirements.getPresentFeatures())) {
        if (logger.isLoggable(FINER)) {
            Set<Feature<?>> missingFeatures = Helpers.copyToSet(requirements.getPresentFeatures());
            missingFeatures.removeAll(features);
            logger.finer(Platform.format("%s: skipping because these features are absent: %s", method, missingFeatures));
        }
        return false;
    }
    if (intersect(features, requirements.getAbsentFeatures())) {
        if (logger.isLoggable(FINER)) {
            Set<Feature<?>> unwantedFeatures = Helpers.copyToSet(requirements.getAbsentFeatures());
            unwantedFeatures.retainAll(features);
            logger.finer(Platform.format("%s: skipping because these features are present: %s", method, unwantedFeatures));
        }
        return false;
    }
    return true;
}
Also used : TesterRequirements(com.google.common.collect.testing.features.TesterRequirements) ConflictingRequirementsException(com.google.common.collect.testing.features.ConflictingRequirementsException) Method(java.lang.reflect.Method) Feature(com.google.common.collect.testing.features.Feature)

Aggregations

ConflictingRequirementsException (com.google.common.collect.testing.features.ConflictingRequirementsException)2 Feature (com.google.common.collect.testing.features.Feature)2 TesterRequirements (com.google.common.collect.testing.features.TesterRequirements)2 Method (java.lang.reflect.Method)2