Compiling test classes that use mock objects from other Netbeans project



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.

.



Relevant Pages

  • Re: Getting started on the HP49g+
    ... either the original HP extable lib ... extable2 lib from http://www.hpcalc.org/details.php?id=3940. ... ask again if you have any problem installing libraries. ... compile the string with ASM (listed in the development lib menu, ...
    (comp.sys.hp48)
  • Re: Seeing Access 2003 table in Access 2007
    ... The reason you're not able to compile is likely because code is running. ... VBA code in your database will not be disabled from the get-go. ... I had a second missing reference which I ... Compile {ProjectName}, where is the name of your VBA ...
    (microsoft.public.access.gettingstarted)
  • Re: 7.0 wishlist?
    ... doing it at compile time runs into the problems shown. ... At least an NPE in seemingly-null-safe could would then be prima facie evidence of thread-unsafety in the null's source chain, and with a runtime check on the reference assignment the NPE will occur in one of blocks that participated in a race condition instead of somewhere random later on. ... void method ... For that, I have the thread hold the queue in a WeakReferenceand if the removemethod hits the timeout, it sleeps for a while holding no other references to the queue. ...
    (comp.lang.java.programmer)
  • Re: Help on designing a modular ASP.NET architecture
    ... It's definately a way to modularise a WebSite, and you can compile them, and reference and use them across projects. ... You don't necessarily have to use controls, but they are nice if there's set pieces of functionality you want to reuse. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Database Crashes when opening table or query in design view
    ... your info, and for reference, there was an option on the change/uninstall on ... Compact the database to get rid of this junk: ... Still in the code window, choose Compile from the Debug menu. ...
    (microsoft.public.access.tablesdbdesign)