Add missing test for JUnit 4 exclusion

See gh-905
This commit is contained in:
Stephane Nicoll 2019-06-19 14:50:32 +02:00
parent 6c79192e75
commit 1c7a73c29f
2 changed files with 52 additions and 0 deletions

View File

@ -164,6 +164,31 @@ class GradleProjectGenerationConfigurationTests {
assertThat(lines).doesNotContainSequence("test {", " useJUnitPlatform()", "}");
}
@Test
void testStarterExcludesVintageEngineAndJUnitWithCompatibleVersion() {
ProjectDescription description = new ProjectDescription();
description.setPlatformVersion(Version.parse("2.2.0.M4"));
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'",
" exclude group: 'junit', module: 'junit'", " }");
}
@Test
void testStarterDoesNotExcludesVintageEngineAndJUnitWithIncompatibleVersion() {
ProjectDescription description = new ProjectDescription();
description.setPlatformVersion(Version.parse("2.1.6.RELEASE"));
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).doesNotContain("exclude group");
}
static Stream<Arguments> annotationProcessorScopeBuildParameters() {
return Stream.of(Arguments.arguments("1.5.17.RELEASE", false), Arguments.arguments("2.0.6.RELEASE", true),
Arguments.arguments("2.1.3.RELEASE", true));

View File

@ -95,4 +95,31 @@ class MavenProjectGenerationConfigurationTests {
assertThat(lines).containsOnlyOnce(" <packaging>war</packaging>");
}
@Test
void testStarterExcludesVintageEngineAndJUnitWithCompatibleVersion() {
ProjectDescription description = new ProjectDescription();
description.setPlatformVersion(Version.parse("2.2.0.M4"));
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>",
" <exclusion>", " <groupId>junit</groupId>",
" <artifactId>junit</artifactId>", " </exclusion>",
" </exclusions>");
}
@Test
void testStarterDoesNotExcludesVintageEngineAndJUnitWithIncompatibleVersion() {
ProjectDescription description = new ProjectDescription();
description.setPlatformVersion(Version.parse("2.1.6.RELEASE"));
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).doesNotContain(" <exclusions>");
}
}