Fraska Portal

Exploring the WebSphere Commerce world

JEE, Play Framework and JUnit

Posted by on in Play Framework
  • Font size: Larger Smaller
  • Hits: 3534
  • 23 Comments
  • Subscribe to this entry
  • Print

Running your first test with Play framework you could face an issue related to the missing Junit libraries, in particular: 

[error] package org.junit does not exist; 

Environment:

  • Mac OS X 10.7.5
  • Eclipse 4.2 Juno
  • JVM 1.6.0_43
  • Play! 2.1.0

Despite your test case is compiled from Eclipse JVM without any warning or error (since Eclipse has in its classpath Junit), at the test execution time, more exactly when you run the command test in the play console, you face the library missing issue:

play! 2.1.0 (using Java 1.6.0_43 and Scala 2.10.0), http://www.playframework.org

> Type "help play" or "license" for more information.
> Type "exit" or use Ctrl+D to leave this console.

[myapp] $ test
[info] Compiling 1 Scala source and 4 Java sources to /myapp/target/scala-2.10/classes...
[error] /myapp/app/models/ModelsTest.java:4: package org.junit does not exist
[error] import org.junit.*;
[error] ^
[error] /myapp/app/models/ModelsTest.java:5: package org.junit does not exist
[error] import static org.junit.Assert.*;
[error]                        ^
[error] /myapp/app/models/ModelsTest.java:6: package play.test does not exist
[error] import play.test.WithApplication;
[error]                 ^
[error] /myapp/app/models/ModelsTest.java:7: package play.test does not exist
[error] import static play.test.Helpers.*;
[error]                        ^

That's could happen cause the unit test case class could have been created under the source app folder. It has to be created under the source folder test. It's pretty intuitive but sometimes we could miss it :-)

 Eclipse Play framework test folder

This time the test will not fail.

Rate this blog entry:
0

Comments

Leave your comment

Guest
Guest Monday, 15 July 2019

Most Popular Post

WebSphere Commerce, the curious life of a front-end catalog request
Core
Rate this blog entry:
5
WebSphere Commerce, the SOLR extension index
Administration
Rate this blog entry:
4
WebSphere Commerce, Data Load and SOLR Delta Index
Data Load
Rate this blog entry:
0

Latest Blogs

WebSphere Commerce, CommandLevelAuthorizationCache
Cache
Rate this blog entry:
0
WebSphere Commerce v8, toolkit exception, ClassNotFound db2
Administration
Rate this blog entry:
1
WebSphere Commerce, ATP migration
Store
Rate this blog entry:
0
WebSphere Commerce, the curious life of a front-end catalog request
Core
Rate this blog entry:
5
WebSphere Commerce, Performance analysis of few European stores
Performance
Rate this blog entry:
0