This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver-ant-tasks.git
The following commit(s) were added to refs/heads/master by this push:
new 865fbbc Parameterize POM creation failure tests
865fbbc is described below
commit 865fbbc42e96368bebdb75cb5b000ab49e9236c3
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Thu Nov 19 00:58:56 2026 +0100
Parameterize POM creation failure tests
---
pom.xml | 5 ++++
.../internal/ant/tasks/CreatePomRainyDayTest.java | 32 ++++++----------------
2 files changed, 13 insertions(+), 24 deletions(-)
diff --git a/pom.xml b/pom.xml
index 16524af..e690568 100644
--- a/pom.xml
+++ b/pom.xml
@@ -202,6 +202,11 @@
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<!-- not needed by Surefire, which adds it; the Ant smoke test in
build.xml runs the tests on the classpath -->
<groupId>org.junit.jupiter</groupId>
diff --git
a/src/test/java/org/apache/maven/resolver/internal/ant/tasks/CreatePomRainyDayTest.java
b/src/test/java/org/apache/maven/resolver/internal/ant/tasks/CreatePomRainyDayTest.java
index f3bc8a1..fbe3383 100644
---
a/src/test/java/org/apache/maven/resolver/internal/ant/tasks/CreatePomRainyDayTest.java
+++
b/src/test/java/org/apache/maven/resolver/internal/ant/tasks/CreatePomRainyDayTest.java
@@ -27,7 +27,8 @@ import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
public class CreatePomRainyDayTest {
@@ -54,36 +55,19 @@ public class CreatePomRainyDayTest {
}
/**
- * Test that the task fails if no groupId is specified and the pom task is
called (default).
+ * Test that the task fails if no groupId or artifactId is specified and
the pom task is called (default).
* Since the failure happens when the task registers the POM, the user can
still create the POM
* if the skipPomRegistration property is set to true.
*/
- @Test
- void noGroupId() {
- configureProject("target/test-classes/ant/createPom/noGroupId.xml",
Project.MSG_VERBOSE);
+ @ParameterizedTest
+ @CsvSource({"noGroupId,noGroupIdSkipRegistration",
"noArtifactId,noArtifactIdSkipRegistration"})
+ void missingCoordinates(String failingFile, String skipRegistrationFile) {
+ configureProject("target/test-classes/ant/createPom/" + failingFile +
".xml", Project.MSG_VERBOSE);
// Expect a BuildException when trying to execute the target
Assertions.assertThrows(BuildException.class, () ->
buildRule.executeTarget("setup"));
// This should work since the setSkipPomRegistration property is set
to true
-
configureProject("target/test-classes/ant/createPom/noGroupIdSkipRegistration.xml",
Project.MSG_VERBOSE);
- buildRule.executeTarget("setup");
- File pomFile = getPomFile();
- Assertions.assertTrue(pomFile.exists(), "The pom file should have been
created at " + pomFile);
- }
-
- /**
- * Test that the task fails if no artifactId is specified and the pom task
is called (default).
- * Since the failure happens when the task registers the POM, the user can
still create the POM
- * if the skipPomRegistration property is set to true.
- */
- @Test
- void noArtifactId() {
- configureProject("target/test-classes/ant/createPom/noArtifactId.xml",
Project.MSG_VERBOSE);
- // Expect a BuildException when trying to execute the target
- Assertions.assertThrows(BuildException.class, () ->
buildRule.executeTarget("setup"));
-
- // This should work since the setSkipPomRegistration property is set
to true
-
configureProject("target/test-classes/ant/createPom/noArtifactIdSkipRegistration.xml",
Project.MSG_VERBOSE);
+ configureProject("target/test-classes/ant/createPom/" +
skipRegistrationFile + ".xml", Project.MSG_VERBOSE);
buildRule.executeTarget("setup");
File pomFile = getPomFile();
Assertions.assertTrue(pomFile.exists(), "The pom file should have been
created at " + pomFile);