ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doron Cohen <>
Subject how to enable Java assertions (ie how to pass '-ea' to the jvm)
Date Thu, 31 May 2007 20:15:55 GMT

Hi, probably a trivial question but I couldn't find a
working answer in the docs/archives/wiki/bugs. I have
a Java assert statement in my code that is supposed
to fail. Java compilation is with -source 1.4, which
compiles these assertions.

When running from Java command line, like this:
  java -ea  junit.textui.TestRunner MyTestClass
or like this
  java -enableassertions junit.textui.TestRunner MyTestClass
The assert  (this is not Junit assert, it is a
Java assert) catches the bug and fails.

But when running the same test case with ant:
  ant test
The assert is not applied and the test passes.

Setting ANT_OPTS to '-ea' or to '-enableassertions'
did not work. This is with both ant 1.7.0 and 1.6.5.

Now this is especially puzzling, since ANT_OPTS does
seem to work. For instance, when I set ANT_OPTS to
'-version', running "ant test" prints the Java version,
just as running "java -version" prints it.

The Java version btw is HotSpot 1.5.0_06.
OS is Windows XP.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message