Skip to content

Sliced tests doesn't reuse cached contexts when testing with Spock's spock.lang.* annotations #8252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ private static final class SpockAnnotationFilter implements AnnotationFilter {

@Override
public boolean isIgnored(Annotation annotation) {
return annotation.annotationType().getName()
.startsWith("org.spockframework.");
return annotation.annotationType().getName().startsWith("org.spockframework.") ||
annotation.annotationType().getName().startsWith("spock.");
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import kotlin.Metadata;
import org.junit.Test;
import org.spockframework.runtime.model.SpecMetadata;

import org.springframework.boot.context.annotation.DeterminableImports;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -69,6 +68,13 @@ public void customizersForTestClassesWithDifferentSpockMetadataAreEqual() {
SecondSpockAnnotatedTestClass.class));
}

@Test
public void customizersForTestClassesWithMixOfSpockAndOtherAnnotationAreNotEqual() {
assertThat(new ImportsContextCustomizer(SecondSpockAnnotatedTestClass.class))
.isNotEqualTo(new ImportsContextCustomizer(
ThirdSpockAnnotatedTestClass.class));
}

@Import(TestImportSelector.class)
@Indicator1
static class FirstImportSelectorAnnotatedClass {
Expand All @@ -93,26 +99,40 @@ static class SecondDeterminableImportSelectorAnnotatedClass {

}

@Import(TestImportSelector.class)
@Metadata(d2 = "foo")
static class FirstKotlinAnnotatedTestClass {

}

@Import(TestImportSelector.class)
@Metadata(d2 = "bar")
static class SecondKotlinAnnotatedTestClass {

}

@SpecMetadata(filename = "foo", line = 10)
@Import(TestImportSelector.class)
@org.spockframework.runtime.model.SpecMetadata(filename = "bar", line = 10)
@Indicator1
static class FirstSpockAnnotatedTestClass {

}

@SpecMetadata(filename = "bar", line = 10)

@Import(TestImportSelector.class)
@spock.lang.Stepwise
@Indicator1
static class SecondSpockAnnotatedTestClass {

}

@Import(TestImportSelector.class)
@spock.lang.Stepwise
@Indicator2
static class ThirdSpockAnnotatedTestClass {

}

@Retention(RetentionPolicy.RUNTIME)
@interface Indicator1 {

Expand Down