Browse Source

Get most of junit task tests running under Surefire

master
Gintas Grigelionis 6 years ago
parent
commit
033fac5b47
3 changed files with 40 additions and 16 deletions
  1. +20
    -4
      src/etc/poms/ant-junit/pom.xml
  2. +9
    -0
      src/etc/poms/ant-junitlauncher/pom.xml
  3. +11
    -12
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java

+ 20
- 4
src/etc/poms/ant-junit/pom.xml View File

@@ -94,10 +94,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<includes>
<include>org/apache/tools/ant/taskdefs/optional/junit/*</include>
</includes>
<excludes>
<exclude>org/apache/tools/ant/taskdefs/optional/junit/JUnit4TestMethodAdapter*</exclude>
<exclude>org/apache/tools/ant/taskdefs/optional/junit/CustomJUnit4TestAdapterCache*</exclude>
</excludes>
<testIncludes>
<include>org/apache/tools/ant/taskdefs/optional/junit/</include>
<include>org/example/junit/</include>
@@ -110,6 +106,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<!-- Cannot exclude JUnit 4-specific classes from compilation because tests depend on them -->
<excludes>
<exclude>org/apache/tools/ant/taskdefs/optional/junit/JUnit4TestMethodAdapter*</exclude>
<exclude>org/apache/tools/ant/taskdefs/optional/junit/CustomJUnit4TestAdapterCache*</exclude>
</excludes>
<archive>
<index>true</index>
<manifest>
@@ -154,6 +155,21 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
</resource>
</resources>
<testResources>
<testResource>
<directory>../../../../src/etc/testcases</directory>
<includes>
<include>taskdefs/optional/junit/**</include>
<include>taskdefs/optional/junit.xml</include>
<include>taskdefs/optional/junitreport.xml</include>
<include>buildfiletest-base.xml</include>
</includes>
</testResource>
<testResource>
<directory>../../../../src</directory>
<includes>
<include>tests/junit/org/apache/tools/ant/taskdefs/optional/junit/*Test.java</include>
</includes>
</testResource>
<testResource>
<directory>../../../../src/tests/junit</directory>
<includes>


+ 9
- 0
src/etc/poms/ant-junitlauncher/pom.xml View File

@@ -122,6 +122,15 @@
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>../../../../src/etc/testcases</directory>
<includes>
<include>taskdefs/optional/junitlauncher.xml</include>
<include>buildfiletest-base.xml</include>
</includes>
</testResource>
</testResources>
<sourceDirectory>../../../../src/main</sourceDirectory>
<testSourceDirectory>../../../../src/tests/junit</testSourceDirectory>
<outputDirectory>../../../../target/${project.artifactId}/classes</outputDirectory>


+ 11
- 12
src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java View File

@@ -272,12 +272,7 @@ public class JUnitLauncherTaskTest {
public void testAntRuntimeLibsCustomLocation() throws Exception {
final String targetName = "test-ant-runtime-lib-custom-location";
final Path trackerFile = setupTrackerProperty(targetName);
// setup a property that points to the locations of Ant runtime classes.
// this path will then be used in target to create a duplicate copied
// classes and then will be used as a custom location for Ant runtime libraries
final String projectResourceName = LoaderUtils.classNameToResource(Project.class.getName());
final File antClassesPath = LoaderUtils.getResourceSource(Project.class.getClassLoader(), projectResourceName);
buildRule.getProject().setProperty("ant.runtime.classes.original.path", antClassesPath.getAbsolutePath());
setupRuntimeClassesProperty();
// run the target
buildRule.executeTarget(targetName);
final String exclusionLogMsg = "Excluding Ant runtime libraries";
@@ -305,12 +300,7 @@ public class JUnitLauncherTaskTest {
public void testAntAndJUnitPlatformLibsCustomLocation() throws Exception {
final String targetName = "test-ant-and-junit-platform-lib-custom-location";
final Path trackerFile = setupTrackerProperty(targetName);
// setup a property that points to the locations of Ant runtime classes.
// this path will then be used in target to create a duplicate copied
// classes and then will be used as a custom location for Ant runtime libraries
final String projectResourceName = LoaderUtils.classNameToResource(Project.class.getName());
final File antClassesPath = LoaderUtils.getResourceSource(Project.class.getClassLoader(), projectResourceName);
buildRule.getProject().setProperty("ant.runtime.classes.original.path", antClassesPath.getAbsolutePath());
setupRuntimeClassesProperty();
// run the target
buildRule.executeTarget(targetName);

@@ -329,4 +319,13 @@ public class JUnitLauncherTaskTest {
final String outputDir = buildRule.getProject().getProperty("output.dir");
return Paths.get(outputDir, filename);
}

private void setupRuntimeClassesProperty() {
// setup a property that points to the locations of Ant runtime classes.
// this path will then be used in target to create a duplicate copied
// classes and then will be used as a custom location for Ant runtime libraries
final String projectResourceName = LoaderUtils.classNameToResource(Project.class.getName());
final File antClassesPath = LoaderUtils.getResourceSource(Project.class.getClassLoader(), projectResourceName);
buildRule.getProject().setProperty("ant.runtime.classes.original.path", antClassesPath.getAbsolutePath());
}
}

Loading…
Cancel
Save