Skip to content

Commit 45f322c

Browse files
committed
chore: extended test
1 parent f7165cc commit 45f322c

File tree

5 files changed

+826
-7
lines changed

5 files changed

+826
-7
lines changed

src/main/java/org/fugerit/java/junit5/tag/check/ExecutedTestTagReporterMojo.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,27 @@
2727
public class ExecutedTestTagReporterMojo extends AbstractMojo {
2828

2929
@Parameter(defaultValue = "${project}", readonly = true, required = true)
30-
private MavenProject project;
30+
protected MavenProject project;
3131

3232
@Parameter(property = "surefire.reports.directory",
3333
defaultValue = "${project.build.directory}/surefire-reports")
34-
private File surefireReportsDirectory;
34+
protected File surefireReportsDirectory;
3535

3636
@Parameter(property = "test.tag.reporter.outputFile",
3737
defaultValue = "${project.build.directory}/executed-test-tag-report.txt")
38-
private File outputFile;
38+
protected File outputFile;
3939

4040
@Parameter(property = "test.tag.reporter.format", defaultValue = "text")
41-
private String format; // text, json, xml, html
41+
protected String format; // text, json, xml, html
4242

4343
@Parameter(property = "test.tag.reporter.requiredTags")
44-
private List<String> requiredTags;
44+
protected List<String> requiredTags;
4545

4646
@Parameter(property = "test.tag.reporter.failOnMissingTag", defaultValue = "false")
47-
private boolean failOnMissingTag;
47+
protected boolean failOnMissingTag;
4848

4949
@Parameter(property = "test.tag.reporter.includeSkipped", defaultValue = "false")
50-
private boolean includeSkipped;
50+
protected boolean includeSkipped;
5151

5252
@Override
5353
public void execute() throws MojoExecutionException {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package org.fugerit.java.junit5.tag.check;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.apache.maven.model.Build;
5+
import org.apache.maven.plugin.MojoExecutionException;
6+
import org.apache.maven.project.MavenProject;
7+
import org.fugerit.java.doc.base.config.DocConfig;
8+
import org.junit.jupiter.api.Order;
9+
import org.junit.jupiter.api.Test;
10+
11+
import java.io.File;
12+
import java.util.Arrays;
13+
14+
import static org.junit.jupiter.api.Assertions.*;
15+
16+
@Slf4j
17+
@Order( 2 ) // must run after ExecutedTestTagReporterMojoTest
18+
class ExecutedTestTagReporterMojoExtendedTest {
19+
20+
@Test
21+
void testExtended() throws MojoExecutionException {
22+
String outputFormat = DocConfig.TYPE_HTML;
23+
File reportFile = new File( String.format( "target/test-extended.%s", outputFormat ) );
24+
log.info( "output file delete : {}", reportFile.delete() );
25+
ExecutedTestTagReporterMojo mojo = new ExecutedTestTagReporterMojo() {
26+
@Override
27+
public void execute() throws MojoExecutionException {
28+
this.format = outputFormat;
29+
this.includeSkipped = Boolean.TRUE;
30+
this.failOnMissingTag = Boolean.FALSE;
31+
this.surefireReportsDirectory = new File( "src/test/sample-surefire-reports" );
32+
this.outputFile = reportFile;
33+
this.project = new MavenProject();
34+
this.requiredTags = Arrays.asList( "helper", "not-found" );
35+
Build build = new Build();
36+
File testClassesDir = new File( "target/test-classes" );
37+
build.setTestOutputDirectory(testClassesDir.getAbsolutePath());
38+
project.setBuild(build);
39+
super.execute();
40+
}
41+
};
42+
mojo.execute();
43+
assertTrue(reportFile.exists());
44+
}
45+
46+
}

src/test/java/org/fugerit/java/junit5/tag/check/ExecutedTestTagReporterMojoTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import org.apache.maven.plugin.MojoExecutionException;
66
import org.apache.maven.project.MavenProject;
77
import org.junit.jupiter.api.BeforeEach;
8+
import org.junit.jupiter.api.Order;
9+
import org.junit.jupiter.api.Tag;
810
import org.junit.jupiter.api.Test;
911
import org.junit.jupiter.api.io.TempDir;
1012

@@ -20,6 +22,7 @@
2022
import static org.junit.jupiter.api.Assertions.*;
2123

2224
@Slf4j
25+
@Order( 1 )
2326
class ExecutedTestTagReporterMojoTest {
2427

2528
@TempDir
@@ -70,6 +73,7 @@ void testExecuteWithNoReports() throws MojoExecutionException {
7073
}
7174

7275
@Test
76+
@Tag("helper")
7377
void testHelperMethods() throws Exception {
7478
// Given: a sample Surefire report
7579
createSampleSurefireReport("TEST-SampleHelperMethodsTest.xml",

0 commit comments

Comments
 (0)