Product Version = NetBeans IDE 7.2 (Build 201207171143)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.7.0_07
Runtime = Java HotSpot(TM) 64-Bit Server VM 23.3-b01
Created attachment 157068 [details]
Tiny test project with package-access src/main class and a corresponding src/test class.
possible duplicates: bug 243784, bug 240025
(bug 240025 mentions that NetBeans offers to rename a test Class when renaming a main class, but not a test package.)
present in NetBeans 8.1RC
The current workaround is to, for example,
- rename the src/main com.sample package to org.example
(which warns you about use by the src/test com.sample package),
- then rename the src/test com.sample package to org.example also.
Renaming the src/main com.sample package introduces import statements into the src/test package files for the src/main classes that were in the same package but are now in the new package. (com.sample.PackageUtilTest now imports org.example.PackageUtil).
If some of these newly imported src/main classes have package-level access, then the system can't compile the src/test classes. (org.example.PackageUtil is package-private, so com.sample.PackageUtilTest cannot import it.) So the src/test package must be renamed to match the src/main package again. (Rename src/test package com.sample to org.example).
After renaming the src/test package, the revised added import statements remain. (org.example.PackageUtilTest has import org.example.PackageUtil). NetBeans marks each one in yellow, warning that it is an import from the same package. To clean up the changeset, these imports can be removed by manually editing each src/test file.
NetBeans would be nicer (and better match its competition) if it offered an option to rename the src/main and src/test packages together, and avoided these issues. (I also tried selecting them both and right-clicking, but that currently disables the refactor menu item.)