Why aren't assert statements working?

You may be finding that assertions that use the assert keyword don't execute.

 

For the Java keyword "assert" to work you have to enable Assertions in the running Java VM (-ea). If your running against a Remote Container, you'll have to start the Remote Java VM with Assertions enabled. If you want to use this Java feature remember to specify the package names of your test classes to avoid assertions all over the Remote Container to be enabled as well.

 

If you are using JBoss AS, the quickest way to setup debug mode is to add the following line to the end of $JBOSS_AS_HOME/bin/run.conf (Unix/Linux):

 

JAVA_OPTS="$JAVA_OPTS -ea"

 

or before the line :JAVA_OPTS_SET in $JBOSS_AS_HOME/bin/run.conf.bat (Windows)

 

set "JAVA_OPTS=%JAVA_OPTS% -ea"

 

Keep in mind your container will always run with assertions enabled after making this change. You might want to consider putting some logic in the run.conf* file.

 

As an alternative, we recommend using the 'Assert' object that comes with your test framework instead to avoid the whole issue.