org.spockframework.runtime.model.FeatureInfo Java Examples

The following examples show how to use org.spockframework.runtime.model.FeatureInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MicronautSpockExtension.java    From micronaut-test with Apache License 2.0 5 votes vote down vote up
private TestContext buildContext(IMethodInvocation invocation, Throwable exception) {
    return new TestContext(
        applicationContext,
        Optional.ofNullable(invocation.getSpec()).map(SpecInfo::getReflection).orElse(null),
        Optional.ofNullable(invocation.getFeature()).map(FeatureInfo::getFeatureMethod).map(MethodInfo::getReflection).orElse(null),
        invocation.getInstance(),
        exception);
}
 
Example #2
Source File: LoggingTestExtension.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Override
public void visitSpecAnnotation(LogTestInformation annotation, SpecInfo spec) {
	for (FeatureInfo feature : spec.getFeatures()) {
		if (!feature.getFeatureMethod().getReflection().isAnnotationPresent(LogTestInformation.class)) {
			intercept(annotation, feature.getFeatureMethod());
		}
	}
}
 
Example #3
Source File: MicronautSpockExtension.java    From micronaut-test with Apache License 2.0 4 votes vote down vote up
@Override
public void visitFeatureAnnotation(MicronautTest annotation, FeatureInfo feature) {
    throw new InvalidSpecException("@%s may not be applied to feature methods")
            .withArgs(annotation.annotationType().getSimpleName());
}
 
Example #4
Source File: FailsWithMessageExtension.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void visitFeatureAnnotation(FailsWithMessage annotation, FeatureInfo feature) {
    feature.getFeatureMethod().addInterceptor(new FailsWithMessageInterceptor(annotation));
}
 
Example #5
Source File: FailsWithMessageExtension.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void visitFeatureAnnotation(FailsWithMessage annotation, FeatureInfo feature) {
    feature.getFeatureMethod().addInterceptor(new FailsWithMessageInterceptor(annotation));
}
 
Example #6
Source File: AllureSpock.java    From allure-java with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeIteration(final IterationInfo iteration) {
    final String uuid = testResults.get();
    final FeatureInfo feature = iteration.getFeature();
    final SpecInfo spec = feature.getSpec();
    final List<Parameter> parameters = getParameters(feature.getDataVariables(), iteration.getDataValues());
    final SpecInfo subSpec = spec.getSubSpec();
    final SpecInfo superSpec = spec.getSuperSpec();
    final String packageName = spec.getPackage();
    final String specName = spec.getName();
    final String testClassName = feature.getDescription().getClassName();
    final String testMethodName = iteration.getName();

    final List<Label> labels = new ArrayList<>(Arrays.asList(
            createPackageLabel(packageName),
            createTestClassLabel(testClassName),
            createTestMethodLabel(testMethodName),
            createSuiteLabel(specName),
            createHostLabel(),
            createThreadLabel(),
            createFrameworkLabel("spock"),
            createLanguageLabel("java")
    ));
    if (Objects.nonNull(subSpec)) {
        labels.add(createSubSuiteLabel(subSpec.getName()));
    }
    if (Objects.nonNull(superSpec)) {
        labels.add(createParentSuiteLabel(superSpec.getName()));
    }
    labels.addAll(getLabels(iteration));
    labels.addAll(getProvidedLabels());

    final TestResult result = new TestResult()
            .setUuid(uuid)
            .setHistoryId(getHistoryId(getQualifiedName(iteration), parameters))
            .setName(firstNonEmpty(
                    testMethodName,
                    feature.getDescription().getDisplayName(),
                    getQualifiedName(iteration)).orElse("Unknown"))
            .setFullName(getQualifiedName(iteration))
            .setStatusDetails(new StatusDetails()
                    .setFlaky(isFlaky(iteration))
                    .setMuted(isMuted(iteration)))
            .setParameters(parameters)
            .setLinks(getLinks(iteration))
            .setLabels(labels);
    processDescription(iteration, result);
    getLifecycle().scheduleTestCase(result);
    getLifecycle().startTestCase(uuid);
}
 
Example #7
Source File: FailsWithMessageExtension.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void visitFeatureAnnotation(FailsWithMessage annotation, FeatureInfo feature) {
    feature.getFeatureMethod().addInterceptor(new FailsWithMessageInterceptor(annotation));
}
 
Example #8
Source File: FailsWithMessageExtension.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void visitFeatureAnnotation(FailsWithMessage annotation, FeatureInfo feature) {
    feature.getFeatureMethod().addInterceptor(new FailsWithMessageInterceptor(annotation));
}