How do you unit test a PlayN project?

251 views Asked by At

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

3

There are 3 answers

1
samskivert On BEST ANSWER

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>
4
Thomas Ahle On

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

I used JUnit with this guide: Using Junit

0
KatGaea On

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.