Core Java

Ant 1.10.3 released with JUnit 5 support

We just released 1.9.11 and 1.10.3 versions of Ant today. The downloads are available on the Ant project’s download page. Both these releases are mainly bug fix releases, especially the 1.9.11 version. The 1.10.3 release is an important one for a couple of reasons. The previous 1.10.2 release, unintentionally introduced a bunch of changes which caused regressions in various places in Ant tasks. These have now been reverted or fixed in this new 1.10.3 version.

In addition to these fixes, this 1.10.3 version of Ant introduces a new junitlauncher task. A while back, the JUnit team has released JUnit 5.x version. This version is a major change from previous JUnit 3.x & 4.x versions, both in terms of how tests are written and how they are executed. JUnit 5 introduces a separation between test launching and test identification and execution. What that means is, for build tools like Ant, there’s now a clear API exposed by JUnit 5 which is solely meant to deal with how tests are launched. Imagine something along the lines of “launch test execution for classes within this directory”. Although Ant’s junit task already supported such construct, the way we used to launch those tests was very specific to Ant’s own implementation and was getting more and more complex. With the introduction of this new API within the JUnit 5 library, it’s much more easier and consistent now to launch these tests.

JUnit 5, further introduces the concept of test engines. Test engines are responsible for “identifying” which classes are actually tests and what semantics to apply to those tests. JUnit 5 by default comes with a “vintage” engine which identifies and runs JUnit 4.x style tests and a “jupiter” engine which identifies and runs JUnit 5.x API based tests.

The “junitlauncher” task in Ant introduces a way to let the build specify which classes to choose for test launching. The goal of this task is to just launch the test execution and let the JUnit 5 framework identify and run the tests. The current implementation shipped in Ant 1.10.3, is the basic minimal for this task. We plan to add more features as we go along and as we get feedback on it. Especially, this new task doesn’t currently support executing these tasks in a separate forked JVM, but we do plan to add that in a subsequent release.

The junit task which has been shipped in Ant since long time back, will continue to exist and can be used for executing JUnit 3.x or JUnit 4.x tests. However, for JUnit 5 support, the junitlauncher task is what will be supported in Ant.

More details about this new task can be found in the junitlauncher’s task manual. Please give it a try and report any bugs or feedback to our user mailing list.

Published on Java Code Geeks with permission by Jaikiran Pai, partner at our JCG program. See the original article here: Ant 1.10.3 released with JUnit 5 support

Opinions expressed by Java Code Geeks contributors are their own.

Jaikiran Pai

Jaikiran works for Red Hat and is a developer in the JBoss application server development team. He's one of the authors of "JBoss AS Getting Started" DZone RefCard. When he's not doing anything JBoss related, you can usually find him at JavaRanch, in his role as a Sheriff(Moderator). He blogs at jaitechwriteups
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Back to top button