This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
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 file nbproject/build-impl.xml. To define the target in build.xml, insert the following lines just below tag <import file="nbproject/build-impl.xml"/>: <target name="-init-macrodef-junit"> <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/1"> <attribute name="includes" default="**/*Test.java"/> <sequential> <junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed"> <jvmarg value="-ea"/> <batchtest todir="${build.test.results.dir}"> <fileset includes="@{includes}" dir="${test.src.dir}"/> </batchtest> <classpath> <path path="${run.test.classpath}"/> </classpath> <syspropertyset> <propertyref prefix="test-sys-prop."/> <mapper to="*" from="test-sys-prop.*" type="glob"/> </syspropertyset> <formatter usefile="false" type="brief"/> </junit> </sequential> </macrodef> </target> 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: http://stackoverflow.com/questions/361975/setting-the-default-java-character-encoding/623036#623036 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. Also see: http://docs.oracle.com/javase/6/docs/platform/jvmti/jvmti.html#tooloptions 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.