JUnit runs tests inside JAR

I use the pure JUnit 4 test, and I compiled them inside some jars belonging to the classpath. I would like to run all the tests in my class.

Is there any way?

My tasks look like this:

<target name="test" description="All the tests"> <junit fork="yes"> <classpath> <path refid="test.classpath" /> <fileset dir="war/WEB-INF/lib/"> <include name="*.jar"/> </fileset> <fileset dir="war/WEB-INF"/> <fileset dir="war"/> </classpath> <formatter type="plain" usefile="false" /> </junit> </target> 
+6
source share
1 answer

The example below assumes that the JUnit tests are called the suffix "Test", such as "MyClassTest.java", and that the Jar JUnit 4 file is located in the library directory pointed to by the lib.dir property. For each jar file containing compiled tests, ZipFileSet can be used to select test classes inside the nested <batchtest> element. The JUnit 4 jar path is included in the class path to ensure that the correct version is being used.

 <target name="test" description="All the tests."> <junit fork="true"> <classpath> <fileset dir="war/WEB-INF/lib/" includes="**/*.jar" /> <fileset dir="${lib.dir}" includes="junit*.jar" /> </classpath> <batchtest haltonfailure="true"> <zipfileset src="war/WEB-INF/lib/test.jar" includes="**/*Test.class" /> </batchtest> <formatter type="plain" usefile="false" /> </junit> </target> 
+5
source

Source: https://habr.com/ru/post/924405/


All Articles