Stop excluding JUnit 4 as of Spring Boot 2.2.0.M5

This commit updates the test starter contributor to only exclude the
vintage engine as excluding junit is no longer necessary.

Closes gh-930
This commit is contained in:
Stephane Nicoll
2019-08-09 15:53:38 +02:00
parent 6422432196
commit 318ffccfe7
3 changed files with 43 additions and 4 deletions

View File

@@ -55,8 +55,9 @@ public class BuildProjectGenerationConfiguration {
}
@Bean
@ConditionalOnPlatformVersion("2.2.0.M3")
public BuildCustomizer<Build> junitJupiterTestStarterContributor() {
@ConditionalOnPlatformVersion("[2.2.0.M3,2.2.0.M4]")
@Deprecated
public BuildCustomizer<Build> junitJupiterLegacyTestStarterContributor() {
return (build) -> build.dependencies().add("test",
Dependency.withCoordinates("org.springframework.boot", "spring-boot-starter-test")
.scope(DependencyScope.TEST_COMPILE)
@@ -64,6 +65,15 @@ public class BuildProjectGenerationConfiguration {
new Exclusion("junit", "junit")));
}
@Bean
@ConditionalOnPlatformVersion("2.2.0.M5")
public BuildCustomizer<Build> junitJupiterTestStarterContributor() {
return (build) -> build.dependencies().add("test",
Dependency.withCoordinates("org.springframework.boot", "spring-boot-starter-test")
.scope(DependencyScope.TEST_COMPILE)
.exclusions(new Exclusion("org.junit.vintage", "junit-vintage-engine")));
}
@Bean
public DefaultStarterBuildCustomizer defaultStarterContributor(InitializrMetadata metadata) {
return new DefaultStarterBuildCustomizer(metadata);

View File

@@ -165,7 +165,8 @@ class GradleProjectGenerationConfigurationTests {
}
@Test
void testStarterExcludesVintageEngineAndJUnitWithCompatibleVersion() {
@Deprecated
void testStarterExcludesVintageEngineAndJUnitWithAppropriateVersion() {
ProjectDescription description = new ProjectDescription();
description.setPlatformVersion(Version.parse("2.2.0.M4"));
description.setLanguage(new JavaLanguage());
@@ -178,6 +179,19 @@ class GradleProjectGenerationConfigurationTests {
" exclude group: 'junit', module: 'junit'", " }");
}
@Test
void testStarterExcludesVintageEngineWithCompatibleVersion() {
ProjectDescription description = new ProjectDescription();
description.setPlatformVersion(Version.parse("2.2.0.M5"));
description.setLanguage(new JavaLanguage());
ProjectStructure projectStructure = this.projectTester.generate(description);
assertThat(projectStructure.getRelativePathsOfProjectFiles()).contains("build.gradle");
List<String> lines = projectStructure.readAllLines("build.gradle");
assertThat(lines).containsSequence(
" testImplementation('org.springframework.boot:spring-boot-starter-test') {",
" exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'", " }");
}
@Test
void testStarterDoesNotExcludesVintageEngineAndJUnitWithIncompatibleVersion() {
ProjectDescription description = new ProjectDescription();

View File

@@ -96,7 +96,8 @@ class MavenProjectGenerationConfigurationTests {
}
@Test
void testStarterExcludesVintageEngineAndJUnitWithCompatibleVersion() {
@Deprecated
void testStarterExcludesVintageEngineAndJUnitWithAppropriateVersion() {
ProjectDescription description = new ProjectDescription();
description.setPlatformVersion(Version.parse("2.2.0.M4"));
description.setLanguage(new JavaLanguage());
@@ -111,6 +112,20 @@ class MavenProjectGenerationConfigurationTests {
" </exclusions>");
}
@Test
void testStarterExcludesVintageEngineWithCompatibleVersion() {
ProjectDescription description = new ProjectDescription();
description.setPlatformVersion(Version.parse("2.2.0.M5"));
description.setLanguage(new JavaLanguage());
ProjectStructure projectStructure = this.projectTester.generate(description);
assertThat(projectStructure.getRelativePathsOfProjectFiles()).contains("pom.xml");
List<String> lines = projectStructure.readAllLines("pom.xml");
assertThat(lines).containsSequence(" <exclusions>", " <exclusion>",
" <groupId>org.junit.vintage</groupId>",
" <artifactId>junit-vintage-engine</artifactId>", " </exclusion>",
" </exclusions>");
}
@Test
void testStarterDoesNotExcludesVintageEngineAndJUnitWithIncompatibleVersion() {
ProjectDescription description = new ProjectDescription();