I wanna do something like
java -enableassertions com.geeksanonymous.TestClass
How do I do this?
To configure assertion options one must use either the -ea or -da command line flags to enable or disable assertions with the command line tool: “java”. For example, “java -ea Assert” where Assert is a java class file. You may also specify a specific class or package as follows.
By default, assertions are disabled. Two command-line switches allow you to selectively enable or disable assertions. With no arguments, the switch enables assertions by default.
You could enable assertions for all packages, then disable them for some of the packages. Or otherwise- disable for all packages, then enable only for some of them.
With a Maven project in netbeans 7.0, choose "File" -> "Project Properties ()".
In the window that appears, choose "Run", and add -enableassertions
to the "VM Options" textbox.
I dont know about Netbeans, but you also can programmatically enable assertions (maybe that helps you as well).
public class WhenRunningTests() {
static {
ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);
}
@Test(expected=AssertionError.class)
public void assertionsShouldBeEnabled() {
assert false;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With