Jeremy G
Jeremy G

Reputation: 568

Unit testing a plug-in: cannot find symbol errors?

I am attempting to get my fragment project to execute unit tests for code in a host project. I am using eclipse, maven, and osgi.

Let's say I have two projects: PluginProject and PluginProject.tests. I am encountering strange behavior in PluginProject.tests.

If I put my unit tests in test/<package-name>, everything builds fine, but the tests are not executed.

If, however, I put my unit tests in src/test/java/<package-name>, then any classes from PlugingProject that I reference (i.e. any of the classes that I am attempting to test) cannot be found. I always get a 'cannot find symbol' error.

Note: my Manifest.MF in PluginProject.test has the following line (among others): Fragment-Host: PluginProjectr;bundle-version="0.0.1"

Has anybody else experience this? I can post more detailed information if necessary. Thanks!

Upvotes: 0

Views: 1084

Answers (1)

Hilikus
Hilikus

Reputation: 10331

My recommended way, like @vikingsteve mentioned, is to have a single project with both your code and your unit tests.

Don't worry, if you follow the standard way (src/main/java and src/test/java) and do a normal mvn package or mvn deploy the test classes will NOT be packaged in the resulting artifact

Upvotes: 2

Related Questions