Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
how to enable Java assertions (ie how to pass '-ea ' to the jvm)

how to enable Java assertions (ie how to pass '-ea ' to the jvm)

2007-05-31       - By Doron Cohen
Reply:     1     2     3     4  


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.

Thanks,
Doron


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.