Skip to content

Commit

Permalink
Merge pull request #41 from M1chaCH/main
Browse files Browse the repository at this point in the history
General improvement & impl. issue #22
  • Loading branch information
pihme authored Mar 4, 2022
2 parents 49c8198 + eb5ff09 commit e202364
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ This plugin scans the XML file for flaky tests results and then generates additi

## How can I configure this plugin?

There are two configuration options:
There are three configuration options:
* `reportDir` (defaultValue `${project.build.directory}/surefire-reports`) - this is the directory that will be scanned for XML report file. It is also the directory to which new XML files will be written
* `failBuild` (defaultValue `true`) - flag to make the plugin fail the build if flaky test were discovered
* `skipFlakyTestExtractor` (defaultValue `false`) - flag to skip this plugin

## What are known shortcomings?

Expand Down
7 changes: 3 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@

<name>flaky-test-extractor Maven Plugin</name>

<prerequisites>
<maven>${maven.version}</maven>
</prerequisites>

<parent>
<groupId>org.camunda</groupId>
<artifactId>camunda-release-parent</artifactId>
Expand Down Expand Up @@ -180,6 +176,9 @@
<configuration>
<rules>
<dependencyConvergence />
<requireMavenVersion>
<version>${maven.version}</version>
</requireMavenVersion>
</rules>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@ public class FlakyTestExtractorPlugin extends AbstractMojo {
@Parameter(defaultValue = "${project.build.directory}/surefire-reports", property = "reportDir")
protected File reportDir;

@Parameter(defaultValue = "true", property = "failBuild", required = false)
@Parameter(defaultValue = "true", property = "failBuild")
protected boolean failBuild = true;

@Parameter(defaultValue = "false", property = "skipFlakyTestExtractor")
protected boolean skip = false;

public void execute() throws MojoFailureException {
if(skip){
getLog().info("extract-flaky-tests Plugin skipped");
return;
}

getLog().info("FlakyTestExtractorPlugin - starting");
getLog().info("reportDir: " + reportDir.getAbsolutePath());
getLog().info("failBuild: " + failBuild);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void createTestSuiteElement(final XMLWriter ppw, final ExtendedReportTes
ppw.addAttribute("xsi:noNamespaceSchemaLocation", xsdSchemaLocation);
ppw.addAttribute("version", xsdVersion);

final String reportName = testSuite.getName();
final String reportName = testSuite.getFullClassName();
ppw.addAttribute("name", reportName == null ? "" : extraEscapeAttribute(reportName));
ppw.addAttribute("time", String.valueOf(testSuite.getTimeElapsed()));
ppw.addAttribute("tests", String.valueOf(testSuite.getNumberOfTests()));
Expand All @@ -100,7 +100,7 @@ private void startTestElement(final XMLWriter ppw, final ExtendedReportTestCase
final String name = testCase.getName();
ppw.addAttribute("name", name == null ? "" : extraEscapeAttribute(name));

final String className = testCase.getClassName();
final String className = testCase.getFullClassName();
if (className != null) {
ppw.addAttribute("classname", extraEscapeAttribute(className));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ public void testExecuteWithFailBuildFalse() throws Exception {
}).doesNotThrowAnyException();
}

@Test
public void testExecuteWithSkipped() {
FlakyTestExtractorPlugin sut = new FlakyTestExtractorPlugin();
sut.reportDir = tempFolder.getRoot();
sut.skip = true;

assertThatCode(sut::execute).doesNotThrowAnyException();

File[] createdFiles = tempFolder.getRoot().listFiles(file -> file.getName().endsWith("-FLAKY.xml"));
assertThat(createdFiles).isEmpty();
}

private void inspectFlakyErrorReport(File flakyErrorReport)
throws ParserConfigurationException, SAXException, IOException, FileNotFoundException {

Expand Down

0 comments on commit e202364

Please sign in to comment.