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.
Summary: | Add support for execution/debugging of a single test method | ||
---|---|---|---|
Product: | java | Reporter: | Marian Petras <mpetras> |
Component: | Project | Assignee: | Tomas Zezula <tzezula> |
Status: | STARTED --- | ||
Severity: | blocker | CC: | jglick, junit-issues, lhanson |
Priority: | P2 | ||
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | TASK | Exception Reporter: | |
Bug Depends on: | |||
Bug Blocks: | 72080, 142763 | ||
Attachments: |
visual diff of suggested changes in build-impl.xml - run single test method
visual diff of suggested changes in build-impl.xml - debug single test method visual diff of suggested changes in build-impl.xml - debug single test method - corrected suggested patch (J2SEActionProvider.java, build-impl.xsl) |
Description
Marian Petras
2008-08-01 13:59:20 UTC
Is this going to be implemented for 6.5? Is there a corresponding issue for apisupport/project? Seems misleading for issue #72080 to be marked FIXED when in fact you cannot use it yet. Partially implemented - for the case that "Compile on Save" is enabled. Changeset Id: bf6e5ac3b136 (http://hg.netbeans.org/main/rev/bf6e5ac3b136) It is going to be implemented. I just filed an issue for apisupport/project: #142763. Integrated into 'main-golden', available in build *200808041401* on http://bits.netbeans.org/dev/nightly/ Changeset: http://hg.netbeans.org/main/rev/bf6e5ac3b136 User: Marian Petras <mpetras@netbeans.org> Log: Partially implemented support for execution/debugging of a single test method (task #142579) - for "compile on save" only for now. Marian: It seems that "methodname" is now a permitted parameter for ProjectRunner.QUICK_TEST{,_DEBUG} yet this fact is not documented. It needs to be. Marian: while Run Again seems to work, Debug runs all the tests in the suite in the debugger. FYI: adding comparable support to automatic projects, in contrib #8523feba7521. I just found the cause of the issue when debugging. The problem is in the classpath. When a test is to be debugged, it is started with the following command (template): <java classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" fork="true" dir="${work.dir}" jvm="${platform.java}"> <classpath> <path path="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar"/> <path path="${classpath-translated}"/> </classpath> ... </java> The substantial thing is that the classpath does not contain the Ant patch that modifies the JUnitTestRunner such that it accepts (and uses) command-line argument "methods=...". The fix is to put the .jar containing the patch to the classpath such that it is before "ant-junit.jar". To make it working also with other Ant patches, I will put it to the beginning of the classpath: <classpath> <fileset dir="${ant.home}" includes="patches/*.jar"/> <path path="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar"/> <path path="${classpath-translated}"/> </classpath> <fileset dir="${ant.home}" includes="patches/*.jar"/> sounds good to me. I guess I should have opened a separate issue. Separate issue against which module? I looked at the Ant build script and an ideal solution would be to define a classpath for Ant and assign it a specific Id (<path id="...">). This path would contain ${ant.home}/lib/ant.jar and all Ant patches. All the tasks could then use this path using <path refid="...">). But I do not know whether it is acceptable as almost any change of Ant script is also an API change. Created attachment 66831 [details]
visual diff of suggested changes in build-impl.xml - run single test method
Created attachment 66832 [details]
visual diff of suggested changes in build-impl.xml - debug single test method
Created attachment 66849 [details]
visual diff of suggested changes in build-impl.xml - debug single test method - corrected
Correction: The updated (corrected) diff is for "run single test method". Created attachment 66850 [details]
suggested patch (J2SEActionProvider.java, build-impl.xsl)
Oh, you are talking about running/debugging a single test method from the regular Ant script. I did not even realize there was any plan to support that. I was talking about Quick Run/Debug on tests, which seems more useful and is anyway much simpler to implement: to make Debug work from the JUnit Results Window you need only change java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-debug-snippet.xml to include ant/patches/*.jar in the classpath. I have already committed (but not pushed yet) the fix in junit-debug-snippet.xml. I pushed the fix of junit-debug-snippet.xml: http://hg.netbeans.org/main/rev/c9208633ed4e I can confirm that #c9208633ed4e enables debug single test method for Google Guice dev sources opened as an automatic project. Already works with CoS enabled; just need it to be made to work also with CoS off (i.e. using build-impl.xml). |