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 189117 - Maven: Surefire's workingDirectory not set for "Test file" action
Summary: Maven: Surefire's workingDirectory not set for "Test file" action
Status: RESOLVED INVALID
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 6.x
Hardware: PC Other
: P3 normal with 1 vote (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-01 19:12 UTC by pekarna
Modified: 2011-03-07 15:41 UTC (History)
0 users

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 pekarna 2010-08-01 19:12:13 UTC
STR:

1) Create a maven project.
2) Write a JUnit test:

public class MyTest extends TestCase {
  @Override protected void setUp() throws Exception {
    System.out.println("Current workdir: " + System.getProperty("user.dir"));
  }
}

3) Set the project's working directory to something else than project's dir:
     File -> Project properties... Run -> Working directory
4) Run the test:  Run -> Test file
5) The test will print project's base dir as CWD.

So, the Working dir does not apply for Surefire's actions.
It would be nice to have this working.
Even better would be if user could override it for specific Action - i.e.:
     File -> Project properties... Actions -> ...

When the POM has Surefire's workingDirectory property set,
it would be also overriden if user set's it in NetBeans.
Comment 1 pekarna 2010-08-01 21:14:20 UTC
Actually, it might be Surefire's bug. I've tried to modify workingDirectory by hand and run the goal from a console, and I can't get it working, either.
Comment 2 Jesse Glick 2011-03-07 15:41:37 UTC
The Run panel only customizes the actual Run action, which is an IDE-managed use of exec:exec. To adjust CWD for Surefire, use e.g.

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.7.2</version>
                <configuration>
                    <workingDirectory>${java.io.tmpdir}</workingDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>