Skip to content

Commit

Permalink
Fix ITs
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-o committed Jan 8, 2024
1 parent 3946940 commit f9e6c74
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class AggregateReportIT extends SurefireJUnit4IntegrationTestCase {
public void aggregateReport() {
OutputValidator outputValidator =
unpack("/aggregate-report").addSurefireReportGoal().executeCurrentGoals();
TestFile surefireReportHtml = outputValidator.getSiteFile("surefire.html");
assertTrue("surefire report missing: " + surefireReportHtml.getAbsolutePath(), surefireReportHtml.exists());
TestFile reportFile = outputValidator.getReportsFile("surefire.html");
assertTrue("surefire report missing: " + reportFile.getAbsolutePath(), reportFile.exists());

// TODO HtmlUnit tests on the surefire report

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void testNgReport() {
.addSurefireReportGoal()
.executeCurrentGoals()
.verifyErrorFree(3)
.getSiteFile("surefire.html")
.getReportsFile("surefire.html")
.assertFileExists();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ public MavenLauncher showExceptionMessages() {
return this;
}

public MavenLauncher deleteSiteDir() {
public MavenLauncher deleteReportsDir() {
try {
FileUtils.deleteDirectory(getValidator().getSubFile("site"));
FileUtils.deleteDirectory(getValidator().getSubFile("reports"));
} catch (IOException e) {
throw new SurefireVerifierException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ public TestFile getSiteFile(String fileName) {
return new TestFile(new File(targetDir, fileName), this);
}

public TestFile getReportsFile(String fileName) {
File targetDir = getSubFile("target/reports");
return new TestFile(new File(targetDir, fileName), this);
}

public File getBaseDir() {
return baseDir;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public File getUnpackedAt() {
}

public SurefireLauncher addFailsafeReportOnlyGoal() {
mavenLauncher.addGoal(getReportPluginGoal(":failsafe-report-only"));
mavenLauncher.addGoal(getReportPluginGoal("failsafe-report-only"));
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ public class Surefire260TestWithIdenticalNamesIT extends SurefireJUnit4Integrati
public void testWithIdenticalNames() throws IOException {
OutputValidator validator = unpack("surefire-260-testWithIdenticalNames")
.failNever()
.addGoal("site")
.addSurefireReportGoal()
.executeCurrentGoals();

TestFile siteFile = validator.getSiteFile("surefire.html");
final URI uri = siteFile.toURI();
TestFile reportsFile = validator.getReportsFile("surefire.html");
final URI uri = reportsFile.toURI();

try (WebClient webClient = new WebClient()) {
HtmlPage page = webClient.getPage(uri.toURL());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public void testReportWithAggregate() {
surefireLauncher.executeTest();
surefireLauncher.addGoal("-Daggregate=true");
OutputValidator validator = surefireLauncher.executeSurefireReport();
TestFile siteFile = validator.getSiteFile("surefire.html");
siteFile.assertContainsText("MyModule1ClassTest");
siteFile.assertContainsText("MyModule2ClassTest");
siteFile.assertContainsText("MyDummyClassM1Test");
TestFile reportFile = validator.getReportsFile("surefire.html");
reportFile.assertContainsText("MyModule1ClassTest");
reportFile.assertContainsText("MyModule2ClassTest");
reportFile.assertContainsText("MyDummyClassM1Test");
}

@Test
Expand All @@ -51,9 +51,9 @@ public void testReportWithoutAggregate() throws Exception {
surefireLauncher.reset();
surefireLauncher.executeSurefireReport();
OutputValidator module1 = surefireLauncher.getSubProjectValidator("module1");
TestFile siteFile = module1.getSiteFile("surefire.html");
siteFile.assertContainsText("MyModule1ClassTest");
siteFile.assertContainsText("MyDummyClassM1Test");
TestFile reportFile = module1.getReportsFile("surefire.html");
reportFile.assertContainsText("MyModule1ClassTest");
reportFile.assertContainsText("MyDummyClassM1Test");
}

public SurefireLauncher unpack() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public void testRussianLocaleReport() {
.addSurefireReportGoal()
.executeCurrentGoals();

TestFile siteFile = validator.getSiteFile("surefire.html");
assertTrue("Expecting file", siteFile.exists());
siteFile.assertContainsText("027"); // Avoid asserting with the "," or "." ;)
TestFile reportFile = validator.getReportsFile("surefire.html");
assertTrue("Expecting file", reportFile.exists());
reportFile.assertContainsText("027"); // Avoid asserting with the "," or "." ;)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Surefire772BothReportsIT extends SurefireJUnit4IntegrationTestCase

public SurefireLauncher unpack() {
SurefireLauncher unpack = unpack("/surefire-772-both-reports");
unpack.maven().deleteSiteDir().skipClean().failNever();
unpack.maven().deleteReportsDir().skipClean().failNever();
return unpack;
}

Expand All @@ -45,11 +45,11 @@ public void testReportGeneration() {
OutputValidator outputValidator =
unpack().addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals();

TestFile siteFile = outputValidator.getSiteFile("surefire.html");
assertTrue("Expecting surefire report file", siteFile.isFile());
TestFile reportFile = outputValidator.getReportsFile("surefire.html");
assertTrue("Expecting surefire report file", reportFile.isFile());

siteFile = outputValidator.getSiteFile("failsafe.html");
assertTrue("Expecting failsafe report file", siteFile.isFile());
reportFile = outputValidator.getReportsFile("failsafe.html");
assertTrue("Expecting failsafe report file", reportFile.isFile());
}

@Test
Expand All @@ -59,11 +59,11 @@ public void testSkippedFailsafeReportGeneration() {
.addSurefireReportOnlyGoal()
.executeCurrentGoals();

TestFile siteFile = validator.getSiteFile("surefire.html");
assertTrue("Expecting surefire report file", siteFile.isFile());
TestFile reportFile = validator.getReportsFile("surefire.html");
assertTrue("Expecting surefire report file", reportFile.isFile());

siteFile = validator.getSiteFile("failsafe.html");
assertFalse("Expecting no failsafe report file", siteFile.isFile());
reportFile = validator.getReportsFile("failsafe.html");
assertFalse("Expecting no failsafe report file", reportFile.isFile());
}

@Test
Expand All @@ -74,10 +74,10 @@ public void testSkippedSurefireReportGeneration() {
.addSurefireReportOnlyGoal()
.executeCurrentGoals();

TestFile siteFile = validator.getSiteFile("surefire.html");
assertFalse("Expecting no surefire report file", siteFile.isFile());
TestFile reportFile = validator.getReportsFile("surefire.html");
assertFalse("Expecting no surefire report file", reportFile.isFile());

siteFile = validator.getSiteFile("failsafe.html");
assertTrue("Expecting failsafe report file", siteFile.isFile());
reportFile = validator.getReportsFile("failsafe.html");
assertTrue("Expecting failsafe report file", reportFile.isFile());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void testReportGeneration() throws Exception {
unpack().addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals();

assertSurefireReportPresent(site);
assertNoFailsefeReport(site);
assertNoFailsafeReport(site);
}

@Test
Expand All @@ -51,7 +51,7 @@ public void testSkippedFailsafeReportGeneration() throws Exception {
.addSurefireReportOnlyGoal()
.executeCurrentGoals();
assertSurefireReportPresent(validator);
assertNoFailsefeReport(validator);
assertNoFailsafeReport(validator);
}

@Test
Expand All @@ -73,27 +73,27 @@ public void testSkipForcedFailsafeReportGeneration() throws Exception {
.executeCurrentGoals();

assertSurefireReportPresent(validator);
assertNoFailsefeReport(validator);
assertNoFailsafeReport(validator);
}

private void assertNoFailsefeReport(OutputValidator site) {
TestFile siteFile = site.getSiteFile("failsafe.html");
assertFalse("Expecting no failsafe report file", siteFile.isFile());
private void assertNoFailsafeReport(OutputValidator validator) {
TestFile reportFile = validator.getReportsFile("failsafe.html");
assertFalse("Expecting no failsafe report file", reportFile.isFile());
}

private void assertFailsafeReport(OutputValidator site) {
TestFile siteFile = site.getSiteFile("failsafe.html");
assertTrue("Expecting no failsafe report file", siteFile.isFile());
private void assertFailsafeReport(OutputValidator validator) {
TestFile reportFile = validator.getReportsFile("failsafe.html");
assertTrue("Expecting no failsafe report file", reportFile.isFile());
}

private void assertSurefireReportPresent(OutputValidator site) {
TestFile siteFile = site.getSiteFile("surefire.html");
assertTrue("Expecting surefire report file", siteFile.isFile());
private void assertSurefireReportPresent(OutputValidator validator) {
TestFile reportFile = validator.getReportsFile("surefire.html");
assertTrue("Expecting surefire report file", reportFile.isFile());
}

private SurefireLauncher unpack() throws VerificationException {
final SurefireLauncher unpack = unpack("surefire-772-no-failsafe-reports");
unpack.maven().deleteSiteDir().skipClean().failNever().verifyFileNotPresent("site");
unpack.maven().deleteReportsDir().skipClean().failNever().verifyFileNotPresent("reports");
return unpack;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public void testReportGeneration() {
OutputValidator validator =
unpack().addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals();

TestFile siteFile = validator.getSiteFile("surefire.html");
assertTrue("Expecting surefire report file", siteFile.isFile());
TestFile reportFile = validator.getReportsFile("surefire.html");
assertTrue("Expecting surefire report file", reportFile.isFile());

siteFile = validator.getSiteFile("failsafe.html");
assertTrue("Expecting failsafe report file", siteFile.isFile());
reportFile = validator.getReportsFile("failsafe.html");
assertTrue("Expecting failsafe report file", reportFile.isFile());
}

@Test
Expand All @@ -52,11 +52,11 @@ public void testSkippedSurefireReportGeneration() {
.addSurefireReportOnlyGoal()
.executeCurrentGoals();

TestFile siteFile = validator.getSiteFile("surefire.html");
assertFalse("Expecting no surefire report file", siteFile.isFile());
TestFile reportFile = validator.getReportsFile("surefire.html");
assertFalse("Expecting no surefire report file", reportFile.isFile());

siteFile = validator.getSiteFile("failsafe.html");
assertTrue("Expecting failsafe report file", siteFile.isFile());
reportFile = validator.getReportsFile("failsafe.html");
assertTrue("Expecting failsafe report file", reportFile.isFile());
}

@Test
Expand All @@ -66,11 +66,11 @@ public void testOptionalSurefireReportGeneration() {
.addSurefireReportOnlyGoal()
.executeCurrentGoals();

TestFile siteFile = validator.getSiteFile("surefire.html");
assertFalse("Expecting no surefire report file", siteFile.isFile());
TestFile reportFile = validator.getReportsFile("surefire.html");
assertFalse("Expecting no surefire report file", reportFile.isFile());

siteFile = validator.getSiteFile("failsafe.html");
assertTrue("Expecting failsafe report file", siteFile.isFile());
reportFile = validator.getReportsFile("failsafe.html");
assertTrue("Expecting failsafe report file", reportFile.isFile());
}

@Test
Expand All @@ -81,16 +81,16 @@ public void testSkipOptionalSurefireReportGeneration() {
.addSurefireReportOnlyGoal()
.executeCurrentGoals();

TestFile siteFile = validator.getSiteFile("surefire.html");
assertFalse("Expecting no surefire report file", siteFile.isFile());
TestFile reportFile = validator.getReportsFile("surefire.html");
assertFalse("Expecting no surefire report file", reportFile.isFile());

siteFile = validator.getSiteFile("failsafe.html");
assertTrue("Expecting failsafe report file", siteFile.isFile());
reportFile = validator.getReportsFile("failsafe.html");
assertTrue("Expecting failsafe report file", reportFile.isFile());
}

public SurefireLauncher unpack() {
SurefireLauncher unpack = unpack("/surefire-772-no-surefire-reports");
unpack.maven().failNever().deleteSiteDir().skipClean();
unpack.maven().failNever().deleteReportsDir().skipClean();
return unpack;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public void testReportGeneration() {
OutputValidator validator =
unpack().addFailsafeReportOnlyGoal().addSurefireReportOnlyGoal().executeCurrentGoals();

TestFile siteFile = validator.getSiteFile("surefire.html");
assertTrue("Expecting surefire report file", siteFile.isFile());
TestFile reportFile = validator.getReportsFile("surefire.html");
assertTrue("Expecting surefire report file", reportFile.isFile());

siteFile = validator.getSiteFile("failsafe.html");
assertTrue("Expecting failsafe report file", siteFile.isFile());
reportFile = validator.getReportsFile("failsafe.html");
assertTrue("Expecting failsafe report file", reportFile.isFile());
}

@Test
Expand All @@ -52,11 +52,11 @@ public void testSkippedFailsafeReportGeneration() {
.addSurefireReportOnlyGoal()
.executeCurrentGoals();

TestFile siteFile = validator.getSiteFile("surefire.html");
assertTrue("Expecting surefire report file", siteFile.isFile());
TestFile reportFile = validator.getReportsFile("surefire.html");
assertTrue("Expecting surefire report file", reportFile.isFile());

siteFile = validator.getSiteFile("failsafe.html");
assertFalse("Expecting no failsafe report file", siteFile.isFile());
reportFile = validator.getReportsFile("failsafe.html");
assertFalse("Expecting no failsafe report file", reportFile.isFile());
}

@Test
Expand All @@ -66,16 +66,16 @@ public void testSkippedSurefireReportGeneration() {
.addSurefireReportOnlyGoal()
.executeCurrentGoals();

TestFile siteFile = validator.getSiteFile("surefire.html");
assertFalse("Expecting no surefire report file", siteFile.isFile());
TestFile reportFile = validator.getReportsFile("surefire.html");
assertFalse("Expecting no surefire report file", reportFile.isFile());

siteFile = validator.getSiteFile("failsafe.html");
assertTrue("Expecting failsafe report file", siteFile.isFile());
reportFile = validator.getReportsFile("failsafe.html");
assertTrue("Expecting failsafe report file", reportFile.isFile());
}

public SurefireLauncher unpack() {
SurefireLauncher unpack = unpack("/surefire-772-specified-reports");
unpack.maven().deleteSiteDir().skipClean().failNever();
unpack.maven().deleteReportsDir().skipClean().failNever();
return unpack;
}
}

0 comments on commit f9e6c74

Please sign in to comment.