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.

Bug 147188 - implement testng maven integration
Summary: implement testng maven integration
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: TestNG (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Lukas Jungmann
URL: http://statistics.netbeans.org/except...
Keywords:
: 146853 (view as bug list)
Depends on: 149981
Blocks: 89008
  Show dependency tree
 
Reported: 2008-09-13 22:36 UTC by shooley
Modified: 2008-11-26 14:59 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 111634


Attachments
stacktrace (2.86 KB, text/plain)
2008-09-13 22:36 UTC, shooley
Details

Note You need to log in before you can comment on or make changes to this bug.
Description shooley 2008-09-13 22:36:18 UTC
Build: NetBeans IDE Dev (Build 200809130201)
VM: Java HotSpot(TM) Client VM, 1.5.0_13-119, Java(TM) 2 Runtime Environment, Standard Edition, 1.5.0_13-b05-237
OS: Mac OS X, 10.5.4, i386

User Comments: 


Stacktrace: 
java.lang.NullPointerException: Must pass non-null build script
        at org.apache.tools.ant.module.api.support.ActionUtils.runTarget(ActionUtils.java:82)
        at org.netbeans.modules.contrib.testng.actions.RunTestClassAction.performAction(RunTestClassAction.java:58)
        at org.openide.util.actions.NodeAction.performAction(NodeAction.java:289)
        at org.openide.util.actions.CallableSystemAction$1.run(CallableSystemAction.java:118)
        at org.netbeans.modules.openide.util.ActionsBridge.doPerformAction(ActionsBridge.java:77)
        at org.openide.util.actions.CallableSystemAction.actionPerformed(CallableSystemAction.java:114)
Comment 1 shooley 2008-09-13 22:36:25 UTC
Created attachment 69810 [details]
stacktrace
Comment 2 Jesse Glick 2008-09-14 21:35:25 UTC
No apparent category for testng module yet, so passing along to junit owner for now.
Comment 3 shooley 2008-09-16 22:16:17 UTC
Sorry, I thought I had added some comments to this.  I saw this on a multi-module maven projects. After right clicking
on my test I chose TestNG -> Run Test Class and got this exception. 
Comment 4 Lukas Jungmann 2008-10-08 15:33:57 UTC
*** Issue 146853 has been marked as a duplicate of this issue. ***
Comment 5 Lukas Jungmann 2008-10-08 15:46:13 UTC
Maven related...
Comment 6 Milos Kleint 2008-10-08 18:20:13 UTC
most probably the testng module assumes AntArtifact and a build script. Which is a wrong assumption for maven projects.
Comment 7 Lukas Jungmann 2008-10-08 20:56:37 UTC
Yes, I haven't been thinking about (supporting) maven :-(

Anyway I tried to do some research in this area and I think I've found what I need to do in order to support it:
 when one creates testng test I need to add a surefire plugin definition into project's pom (if it isn't there already)
with a pointer to test config file[1] and point actions to run maven (test) goals instead of ant targets. Question is -
can I do all this stuff from my module or does it need to be done directly in meven ide modules?

Any help and/or pointers are appreciated.
Thanks.

[1]: http://maven.apache.org/plugins/maven-surefire-plugin/testng.html
Comment 8 Milos Kleint 2008-10-09 06:37:18 UTC
disclaimer: I don't have any personal experience with testng+maven so my assumptions might be wrong.

On the basic level, I think it should be enough to just add the testng dependency to the maven project. That can be done
without depending on maven modules, having a library definition with a valid maven-pom volume and passing it to
ClassPathModifier shall be enough.
if you however need to update the pom, you will indeed need a dependency on the maven modules (unless you want to modify
the raw xml file of course)

for running the tests, I suppose calling the standard ActionProvider's TEST/TEST_SINGLE/DEBUG_SINGLE actions should be
enough. They execute either the test phase, or surefire:test goal and it should not matter if the actual tests are
testng or junit. 

if you figure you need a special module to handle maven testng, then it shall be probably a special bridge module,
depending both on testng module and maven modules.

Comment 9 Milos Kleint 2008-10-09 19:51:42 UTC
changing the subject accordingly to what is required to do.
Comment 10 Lukas Jungmann 2008-10-10 01:11:01 UTC
Thanks Milosi!

http://hg.netbeans.org/main/contrib/rev/9fa2a76431d8 fixes NPE and adds some other minor fixes/improvements

What needs to be done:
-create default testng.xml and add path to pom.xml
-see if changes in testng.xml for running tests will be picked up by maven/surefire plugin to run only a class/method
etc and re-enable (or hide) what's needed

re maven-pom volume: tried this, but PCM doesn't allow me to set scope and classifier for the library (which I need)

re special module: good exercise for me :) definitely better solution, will try to find some time to do it
Comment 11 Milos Kleint 2008-10-10 08:47:31 UTC
scope and classifier fixed
http://hg.netbeans.org/main/rev/6fe12b254c55
http://hg.netbeans.org/main/rev/3c59350d95d3

Comment 12 Quality Engineering 2008-10-10 17:22:21 UTC
Integrated into 'main-golden', will be available in build *200810101401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/6fe12b254c55
User: Milos Kleint <mkleint@netbeans.org>
Log: #147188 encode a classifier in the library's maven-pom volume. Make it part of the url's #ref, rather than path.
Comment 13 Lukas Jungmann 2008-10-15 21:32:17 UTC
thanks, Maven specific behaviour (mainly custom TestNG actions) can be now implemented in contrib's testng.maven module
(look for execute(TestConfig): void there) - module is not in build yet -
http://hg.netbeans.org/main/contrib/rev/e586a681a79a
Comment 14 Lukas Jungmann 2008-10-30 23:30:07 UTC
done in contrib's 0bdb7709773c

current solution is based on adding custom profile into project's pom which is being activated only from IDE by setting
special property, Milos, can I ask you for a review, please?

Thanks.

btw: I already added maven testng module to the dev UC, it should appear there in few hours
Comment 15 Lukas Jungmann 2008-11-26 14:59:15 UTC
=> contrib/testng