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 198912 - Netbeans runs maven projects tests through ant instead of maven surefire
Summary: Netbeans runs maven projects tests through ant instead of maven surefire
Status: RESOLVED INVALID
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.0
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-26 13:09 UTC by edvicif
Modified: 2012-01-03 22:52 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description edvicif 2011-05-26 13:09:28 UTC
Hi!

I think this is a new feature of Netbeans, because previously I didn't have this problem.

When I want to run a unit tests in maven projects under netbeans most of the time it fails.

This is because now unit tests run through ant, which doesn't discovers all environment dependency and doesn't run through all life cycle steps.

It would be nice to be able to configure run-tests to use surefire through maven instead of ant.

Now if I want to run a certain test I have to use Run --> Custom --> Goals... and add test-compile surefire:test as a target. Set up the profiles manually. Than pass the parameter test=MyTest.

If I want to debug it it. I have to ask to suspend after start and wait for debugger to attach. Than I have to attach remote debugger through netbeans, which again over complicate this simple process a bit.

Other thing is, that when I ask for the settings for the unit test run it shows a tiny window about the ant properties it uses to call my tests. If I enlarge the window the GUI elements doesn't grow with it. This makes really hard to debug, why certain unit test unable to run, through this ant function.
Comment 1 Jesse Glick 2011-05-27 12:18:28 UTC
The default behavior, for speed, is to just pick up the (scope=test) classpath definition from Maven, add in project classes as parsed by the IDE's editor, and then run JUnit directly (the fact that Ant's <junit> is currently used for this purpose is incidental). Set File > Project Properties > Compile > Compile on Save to "Disable" if you prefer to use Surefire even for running/debugging individual test cases. This will have more overhead but will work better for projects using complex Surefire configuration.
Comment 2 trebuchetguy 2012-01-03 18:33:38 UTC
I am experiencing the same problem, and the fix listed below does resolve it, however:
-It does not seem that the feature of using Surefire and using "compile on save" should be linked in this regard. These are two distinct features and should be able to be configured independently. This seems like a bug to me.
-Also, there is another workaround for this problem that doesn't seem to comply with this explanation. If a user manually edits the pom.xml, saves it, then re-runs the test, the Surefire action (and not the Ant task) will run once. If the user tries to run it again (with out modifying the pom.xml), the Ant Task will execute instead.
Comment 3 Jesse Glick 2012-01-03 22:52:13 UTC
(In reply to comment #2)
> It does not seem that the feature of using Surefire and using "compile on
> save" should be linked in this regard. These are two distinct features

No they are not. Either the IDE launches Maven with the Surefire goals; or it calls an API to directly run internally-compiled classes, which currently happens to use Ant's <junit>.

> If a user manually edits the pom.xml, saves it, then
> re-runs the test, the Surefire action (and not the Ant task) will run once.

Under certain conditions the internally-compiled classes are either unavailable or expected to be out of date, in which case Surefire is run even if CoS is enabled generally. Typically CoS is used to quickly rerun a test after making source-code-only changes.