Running tests in Eclipse and IntelliJ

33 views
Skip to first unread message

kk

unread,
Feb 24, 2017, 3:06:23 AM2/24/17
to BaasBox
Hi, 

I am wondering how to run the unit tests (e.g. PushSendTest.java) in the 'test' directory? 

Here is what I did on Eclipse: 
1. Open the unit test that I want to run -> Opened PushSendTest.java. 
2. Right click on the class name PushSendTest -> Run As -> JUnitTest. 
3. PushSendTest fails with the following error: 

======================================================
java.lang.AssertionError: Cannot process payload </adminUserCreatePayload.json>. Due to: No content to map due to end-of-input
 at [Source: UNKNOWN; line: 1, column: 1]
at org.junit.Assert.fail(Assert.java:88)
at core.AbstractTest.getPayload(AbstractTest.java:438)
at core.AbstractTest.updatePayloadFieldValue(AbstractTest.java:465)
at PushSendTest.access$0(PushSendTest.java:1)
at PushSendTest$2.run(PushSendTest.java:174)
at play.test.Helpers.running(Helpers.java:376)
at PushSendTest.TestApnServer(PushSendTest.java:165)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.rules.TestWatchman$1.evaluate(TestWatchman.java:53)
at org.junit.rules.Verifier$1.evaluate(Verifier.java:35)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
======================================================

4. Similarly, all the tests fail with some error or failure. 

Can you please guide me on how to run Baasbox tests on Eclipse and IntelliJ? My objective is to add my own unit tests for my project. 

Thanks for the help!

giastfader

unread,
Feb 24, 2017, 3:37:05 AM2/24/17
to BaasBox
Hi,
you have to run tests outside the IDE running "play test".
They need the "play framework" context in order to run.

kk

unread,
Feb 24, 2017, 4:25:09 AM2/24/17
to BaasBox
Thanks a lot!  

Running "play test" just compiled all the source files: 

$ play test

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0

[info] Loading project definition from /Users/Installs/baasbox-0.9.5/project

[info] Set current project to BaasBox (in build file:/Users/Installs/baasbox-0.9.5/)

[info] Compiling 17 Java sources to /Users/Installs/baasbox-0.9.5/target/scala-2.10/classes...

[warn] Note: Some input files use or override a deprecated API.

[warn] Note: Recompile with -Xlint:deprecation for details.

[warn] Note: Some input files use unchecked or unsafe operations.

[warn] Note: Recompile with -Xlint:unchecked for details.

[info] Compiling 93 Java sources to /Users/Installs/baasbox-0.9.5/target/scala-2.10/test-classes...

[warn] Note: Some input files use or override a deprecated API.

[warn] Note: Recompile with -Xlint:deprecation for details.

[warn] Note: Some input files use unchecked or unsafe operations.

[warn] Note: Recompile with -Xlint:unchecked for details.

[success] Total time: 28 s, completed Feb 24, 2017 12:38:07 AM=


Then, I just googled for testing play framework and got this: 

I ran 'test' from the SBT console. Even that just did a build and didn't run any test. 

Can you please provide more information? Really appreciate it. I am new to play and Baasbox. 

kk

unread,
Feb 25, 2017, 4:05:29 AM2/25/17
to BaasBox
Found the "solution". 

Googled it and found out that you need to run play clean to get play framework tests to work sometimes: 

So, I ran play clean-all baas first and then 'play test'. Tests ran fine with a high CPU load on my Macbook Air 4GB RAM 1.8GHz Intel Core i5. :)
Reply all
Reply to author
Forward
0 new messages