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 172997 - Extending internal test-runner by global properties
Summary: Extending internal test-runner by global properties
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: JUnit (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: Victor Vasilyev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-24 11:59 UTC by onmomo
Modified: 2010-01-20 07:02 UTC (History)
2 users (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 onmomo 2009-09-24 11:59:58 UTC
Hi there! I need to run single file test of a maven 2 project (project A). The problem is that I need the full classpath
of the parent pom (project B) of the named project to execute the test.

When I run the single test, it fails because the classpath contains only the files referenced by project A.

Solution in eclipse: I've started the test by creating a run configuration and adding a variable, which contains the
full classpath of project B, to the config.

In NB I've got a variable in build.properties file which contains the full classpath

Solution in netbeans: I load variable in the build.properties file with the maven-properties-plugin and modify the code
from maven-surefire-plugin in the pom, so that i can add the full-classpath in the variable as
"AdditionalClasspathElement" to the plugin classpath. ..Yes very complicated and very costly by editing over 100 pom
files and no possibility to debug the tests.

So there should be a possiblity to add variables/global properties to the junit test-runner in NB. Maybe you could give
me a hint where in the modules, I have to implement this feature?
Comment 1 Milos Kleint 2009-10-12 14:07:27 UTC
well, and what is the solution in maven? it seems to me that your projects are not properly setup. either the test file
is misplaced and shall be in project B instead of A, or the project A's test classpath is wrong. Or you shall move the
test to yet another project C that will depend both the A and B for classpath.

It seems to me like you managed to hack something in eclipse (bypassing maven) and require the same from netbeans.
(Un)fortunately we just use what maven does. So to configure netbeans, you have to configure maven. Then you have both
the command line and maven working..
Comment 2 onmomo 2009-10-14 13:35:34 UTC
"..and what is the solution in maven?"
I agree with your point of view. The reason why I "hack" eclipse for executing maven test is because, i don't have any
other solution.. perhaps you could help me?

I've got a hudge component based software powered of a lot independent components. Just one comp(the starter-comp)
depends on every other component of the software and is needed to run the whole thing.
I wrote a test in one of the components (test-comp), to execute this integration-test, I need a dependency to the
starter-comp or the execution will fail.

I tried to create a new project (test-project) which depends on "test-comp" and "starter-comp" but this failed, because
the test is not in the productive code part of "test-comp" for this reason "test-project" won't see the test.

Do you have any solution managing testing with maven for my situation? The requirement is that i can run single test
from the subcomponents.
Comment 3 Milos Kleint 2009-10-14 13:56:30 UTC
I think you have 2 options
1. move the actual test to test-project (as I understood you just created a test project because of classpath but kept
the test with the component project, is that right?
2. using jar:test-jar execution (http://maven.apache.org/plugins/maven-jar-plugin/test-jar-mojo.html) create an jar with
tests in component project and then in the test project, depend on it using the <classifier> dependency element. That
way you get the tests from component project on classpath of the test project.
Comment 4 onmomo 2009-10-26 16:33:42 UTC
"as I understood you just created a test project because of classpath but kept
the test with the component project, is that right?"
Not exactely.

Testframework: used for starting the application for testing, slim and configurable by Google GUICE, it's used to start
the application with the subcomponents which are needed for the tests in Project X.
Project A-Starter: Features the whole classpath for my Testframework, knows every subcomponent
Project X: A single subcomponent, features "integration-tests" for testing this subcomponent. Starts the Testframework
(but this requires additional dependencies to other subcomponents)

I need to start the testframework from Project X with the full classpath of Project A-Starter. The classpath of
A-Starter would be available in a global property.


Comment 5 onmomo 2009-10-26 16:43:09 UTC
"as I understood you just created a test project because of classpath but kept
the test with the component project, is that right?"
Not exactely.

Testframework: used for starting the application for testing, slim and configurable by Google GUICE, it's used to start
the application with the subcomponents which are needed for the tests in Project X.
Project A-Starter: Features the whole classpath for my Testframework, knows every subcomponent
Project X: A single subcomponent, features "integration-tests" for testing this subcomponent. Starts the Testframework
(but this requires additional dependencies to other subcomponents)

I need to start the testframework from Project X with the full classpath of Project A-Starter. The classpath of
A-Starter would be available in a global property.


Comment 6 Milos Kleint 2009-10-27 13:38:15 UTC
I suppose you need to create Project-X-Integration which will depend on Project-TestFramework and Project-A-Starter and
will contain the integration tests for for project-X components (and any other project-Y components as well for that matter)
Comment 7 onmomo 2010-01-20 07:02:02 UTC
Ok thanks a lot for the tips Milos!
I'll put all Integration-Test into one module and let maven handle the classpath.