I would like to write Ant task which would do exactly the same thing as Maven's Surefire plugin.
The problem is that Surefire is basically a part of Maven so I can't find any information on what it actually does.
(it can use Surefire API for example, but I have no idea how to 开发者_开发问答do this since there is no information even on their site)
Milosz, why would you actually want to do this? Maven is Maven. It has it's own behavior and philosophy. Ant is a different thing. There is already a JUnit executor for Ant (check here).
The surefire plugin is tied to so many other things, that I don't think it would be that trivial to get it to work under Ant. This was not it's purpose in the first place.
Nevertheless, here's an explanation of how things work.
The Maven Surefire plugin consists of two parts:
1) The maven-surefire-plugin. This plugin is used for executing the JUnit tests.
It can be set up as follows:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
</plugin>
...
</plugins>
</build>
...
</project>
2) The maven-surefire-report-plugin used for generating test reports.
It can be set up as follows:
<project>
...
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.9</version>
</plugin>
</plugins>
</reporting>
...
</project>
精彩评论