2

I have managed to get basic unit testing working, however when I add a unit test to project-java I get an error of class not found, looking into it it seems when compiling the testing classes, it dosn't copy the main classes from the project-core, does anyone have any idea how to fix this in maven?

Edit: To make things more clear, I do know where to place the tests, I have placed in project-java/src/tests However What I mean is it doesnt invlude the clases from project-core/src

KatGaea
  • 996
  • 1
  • 12
  • 31

3 Answers3

4

A better approach is to add your tests to core/src/test/java and then add a test dependency on playn-java to your core/pom.xml:

<dependency>
  <groupId>com.googlecode.playn</groupId>
  <artifactId>playn-java</artifactId>
  <version>${playn.version}</version>
  <scope>test</scope>
</dependency>
samskivert
  • 3,694
  • 20
  • 22
1

You need to store all yours tests not in src/main, but in src/test.

I used JUnit with this guide: Using Junit

Thomas Ahle
  • 30,774
  • 21
  • 92
  • 114
  • I do store my tests in the src/test the problem is when testing in maven it Doesn't copy the appropriate classes from core project to java project like it does when running. I know how to use Junit, the trouble is maven does not seem to understand when using the subprojects, to copy the appropriate classes. – KatGaea May 04 '12 at 18:32
  • If you read the guide, it is not about "How to use JUnit", but "How to use JUnit with Maven". – Thomas Ahle May 04 '12 at 21:08
  • Which is again, something I know, and the guide has said nothing new, I already KNEW how to use it with maven, what I dont know is how to make it react properly with subprojects, as it is clearly not doing so with the playn project. – KatGaea May 05 '12 at 00:51
  • Easy mistake to make when you have multiple windows open of similar Questions, it was just a bit of a wtf moment for myself. – KatGaea May 17 '12 at 03:05
0

I went a different route with this in the end, and actually made a playn-testframework. a simple playn- project that acted like playn-java etc, but would not render to screen, and had extra callbacks for the tests to use, such as to simulate mouse/keyboard events.

KatGaea
  • 996
  • 1
  • 12
  • 31