Compiling test classes that use mock objects from other Netbeans project
- From: abbomb@xxxxxxxxxxx
- Date: 30 Aug 2005 10:46:28 -0700
I am encountering a "cannot find symbol" compilation error when I try
to compile a test class that uses mock objects defined in a different
Netbeans project. If it matters, I am using Netbeans 4.0 on Windows.
Let me explain further. I have two Netbeans projects, main and lib.
That leads to the following directory structure:
lib
lib\src
lib\src\com\foocorp\A.java
lib\test
lib\test\com\foocorp\MockA.java
lib\dist\lib.jar
main
main\src
main\src\com\foocorp\B.java
main\test
main\test\com\foocorp\TestB.java
B.java (in the main project) imports com.foocorp.A (from the lib
project) so in the main project I had to add a reference to the lib
project (using "Build->Compiling Sources->Add Project..."). This works
fine and allows B.java to compile perfectly.
The problem arises when I try to compile TestB.java (in the main
project). That file imports com.foocorp.MockA. The reference to the
lib project does not allow TestB.java to compile because the reference
is to "lib\dist\lib.jar" and the JAR file does not include any of the
class files that result from classes in the test directory. Therefore,
when I try to compile TestB.java I get a "cannot find symbol" error on
the line that imports com.foocorp.MockA.
What is the best way to fix this problem?
I could include all of the lib project's test files in lib.jar but I
don't want to do that.
I could move the definition of MockA from the lib project to the main
project but that doesn't work because there are other main projects
that also use the same mock object. There are also test classes in the
lib project that need MockA.
I have tried creating a reference in the main project to the lib
project's test folder (rather than the project reference that creates a
link the lib project's JAR file) but that doesn't help.
.
- Prev by Date: Re: How to read file into array...
- Next by Date: Re: Good books for a complete beginner!
- Previous by thread: NEEDED help
- Next by thread: ANN: Free Online Tutor Classifieds
- Index(es):
Relevant Pages
|