I' useing the given-junit UI from Netbeans 3.6 to
create and run tests.
I noticed that while assert works in my program,
it does not work while testing (Strg+Alt+L).
I have JUnit Execution set to "External" and
external execution has asserts enabled (I also
enabled asserts whereever possible.)
I asked in gmane.java.ide.nebeans.users and got
the reply to post it as a bug here.
The assert statements are ignored because the JVM running the tests
ignores the statements (which is the default behaviour). The problem
is that there is no way for a user how to enable interpreting of the
statements. Generally, there is no way how to pass a JVM parameter to
the JVM starting the tests.
Confirmed. It is possible to do it neither in NB 3.6 nor in NB 4.0.
The problem is that when a separate JVM is started (forked) for
running JUnit tests, no JVM parameters are specified for it and there
is no GUI for doing it.
Currently the only way (I know about) of how to specify JVM parameters
for JVM running JUnit tests is to override Ant target
"-init-macrodef-junit". To override the target, simply define it in
file build.xml in the project's root directory. Once it is defined
there, it will be used instead of the default definition specified in
To define the target in build.xml, insert the following lines just
below tag <import file="nbproject/build-impl.xml"/>:
<attribute name="includes" default="**/*Test.java"/>
<formatter usefile="false" type="brief"/>
The only difference (except formatting) between the original
definition and the new one is that the new definition contains element
<jvmarg value="-ea"/>. One may customize JVM parameters by replacing
"-ea" with any legal JVM parameters.
*** Issue 62337 has been marked as a duplicate of this issue. ***
What about setting value of "jvmarg" attrib for forked JVM in ...
1. Tools-> Options ->jUnit (global settings for all projects) ?
2. Actual Project -> Properties -> new "Test" card with jUnit settings?
Would it be possible?
Reassigned to "java/j2seproject".
Issue #122677 ("Add run.test.jvmargs to project.properties") is related.
See also Issue 152183, maybe related.
*** Bug 122677 has been marked as a duplicate of this bug. ***
*** Bug 185747 has been marked as a duplicate of this bug. ***
I needed to try a JVM option for a unit test to and found this post on SO:
So you can set environment variable JAVA_TOOL_OPTIONS to the required JVM options and they will be picked up by any newly starting JVM.
In my case I set it to -Dfile.encoding=UTF8
and that was picked up correctly after restarting netbeans 7.2.1 on Windows 7.