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 257764 - 'Test File' unit test fails but 'Test' (project) succeeds for maven project
Summary: 'Test File' unit test fails but 'Test' (project) succeeds for maven project
Status: NEW
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 8.1
Hardware: PC Windows 8.1
: P3 normal (vote)
Assignee: Theofanis Oikonomou
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-29 16:55 UTC by RayDeCampo
Modified: 2016-06-20 12:25 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description RayDeCampo 2016-01-29 16:55:11 UTC
I have not been able to create a small set of projects illustrating this issue and unfortunately the project where I have encountered the issue is proprietary so I am limited to just describing the issue.

I have two projects, project A contains annotations and project B is the annotation processor for the annotations.  In project B I am using Mockito to mock instances of the annotations from project A in the test classes.  When I run 'Test File' on one of these unit tests I get a NoClassDefFoundError on the annotation class from project A.

When I run 'Test' on the project all of the tests run and complete successfully.

If I run a focused test outside the IDE using mvn the test completes successfully.

I attempted as best I could to reproduce what NB was doing when running 'Test File' using a command line.  This is what I ran:

set JAVA_HOME=C:\Java\jdk1.7.0_51
set M2_HOME=U:\maven\apache-maven-3.3.3
%M2_HOME%\bin\mvn.cmd ^
    -Dtest=my.test.class.MyTest ^
    -Dmaven.ext.class.path="C:\Program Files\NetBeans 8.1\java\maven-nblib\netbeans-eventspy.jar;C:\Program Files\NetBeans 8.1\java\maven-nblib\netbeans-cos.jar ^
    test-compile surefire:test

The above test ran successfully.

I went into the project properties for project B and changed the 'Test File' action Execute Goals from "test-compile surefire:test" to "test".  After making that change the 'Test File' action would complete successfully.

The configuration change I noted is an acceptable workaround.  Mostly I am just filing this bug for documentation purposes (especially since I can't reproduce it in a project I can supply).