[2.1 scala] specs2 tests running twice

663 views
Skip to first unread message

Alex Varju

unread,
Feb 16, 2013, 6:38:06 PM2/16/13
to play-fr...@googlegroups.com
I've been working on upgrading my codebase to Play 2.1, and one problem I've encountered is with each specs2 test running twice. The root cause of this problem appears to be a combination of SpecificationWithJUnit tests and Play's dependency on com.novocode.junit-interface. We use SpecificationWithJUnit so that Eclipse can run our tests, but the presence of @RunWith annotations seems to cause junit-interface to pick these tests up and run them a second time.

With so many components upgraded in 2.1 it's hard to be certain which specific change actually caused this problem. This issue did not occur with Play 2.0.4, which depended on an older version of junit-interface.

I've managed to work around this by adding the following to my Build.scala:

val appDependencies = Seq("com.novocode" % "junit-interface" % "0.10-M2")
..
val main = play.Project(appName, appVersion, appDependencies).settings(
testOptions += Tests.Argument(TestFrameworks.JUnit, "--ignore-runners=org.specs2.runner.JUnitRunner")
)

This feels pretty hacky, though. Has anybody else run into this issue, and if so, did you have a more graceful solution? What I'd really like to do is exclude the junit-interface dependency altogether, but I don't know how to make sbt do this for me.

Thanks,
Alex.

Eishay Smith

unread,
Feb 28, 2013, 3:03:05 PM2/28/13
to play-fr...@googlegroups.com
fwiw, I have the same problem



--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Asanga Manage

unread,
Sep 9, 2013, 9:27:19 PM9/9/13
to play-fr...@googlegroups.com
We recently decided to use Play framework 2.X (previously used play 1) for our shiny new project and then decided to use Spring MVC after few good weeks of struggling. ! Simply nothing works in play 2. I wonder why the simplest and most important things like running  test case won't work. We use lot of test cases, when ever we run test cases, they run twice, eating up resources and taking 2x time and its bloody hard to find out information about missing test cases since they get prints twice,, every time !. The main selling point regards to test cases with play was the browser based test, in play 2 you don't get it, then if you ever wonder why that test fails and hoping to debug and see, then you are out of luck, Play2 does not allow you to debug test cases ! We waited for 2 consecutive releases hoping these issues will get fix, but still no hope. We are commercial development company and we made this mistake by choosing no matured enough framework to deliver high-end deadline driven commercial product. !

Play 2. Documentation is flawed/incomplete and rather useless. This is not another Scala issue, we are ok with Scala and play 2 with scala is a good decision. This is the simple ignorance of the Play framework developers and they should at-least have the minimum respect towards the people who is going to use this in a commercial world.  Yes, now they can say, "use it or leave it"  , "this is not our day job, we do this for hobby" etc etc ! (I have seen such comments from them ) On that regards, all I have to say is, this framework is only good for Hobby projects, if you do a Day job under real commercial settings, STAY AWAY FROM THIS ! Its not worth. It took us 3 good weeks to change out track and we are happy we did it.

Ben McCann

unread,
Sep 9, 2013, 9:35:29 PM9/9/13
to play-fr...@googlegroups.com
This was a problem with the junit-interface library that Play depends on.  It should be fixed in 2.1.4 and 2.2.0.  Test one of those out and definitely reply back to let us know if it's fixed or not.

Asanga Manage

unread,
Sep 9, 2013, 9:54:35 PM9/9/13
to play-fr...@googlegroups.com
Thanks Ben! I Appreciate your comment.

We downloaded the Play-framework from the official site via the latest stable release which was 2.1.3. Still its 2.1.3 the stable release. (I have no idea why they call is stable).  For the record, I also tried 2.1.4 which is still in RC2, to see if any thing improved, so unlucky me, the test case running twice even in RC2. Anyway for a production system how can I use RC2. 
The one problem with the ideology of PLay 2 guys is, they are too much in to future :) They never realize the future is based on present experience ! They are in the game of developing the Best Java framework for 2050 ! Currently nothing works pretty much, I should come back and see how it goes in 2020 or 2030.

Again, I will try this when I go home. Hopefully It will work.

Ben McCann

unread,
Sep 9, 2013, 10:09:24 PM9/9/13
to play-fr...@googlegroups.com
Oh, if it does not work in 2.1.4-RC2, can you share how to reproduce it?  The Play developers are working to fix all known bugs in Play 2.2.0 before the next RC within the next week, so this is the time to get any bugs fixed!  This is an issue which has been around for awhile that I would very much like to fix.


--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/4Fz5TsOKPio/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

WhyMeLord

unread,
Sep 9, 2013, 10:23:18 PM9/9/13
to play-fr...@googlegroups.com
HI Ben,

We first used, 2.1.3 (official release) then we faced these issue.

Then I personally installed RC2 in my machine, and set the path variables to new RC2. 
with following plugins.sbt in the same Intellij project.

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.1.4-RC2")

with sbt.version=0.12.2

Thats all I remember, the test case was nothing fancy, just a simple crud operation verification. 

Thanks.

Ben McCann

unread,
Sep 9, 2013, 10:33:36 PM9/9/13
to play-fr...@googlegroups.com
Do you have the SpecificationWithJUnit / @RunWith portion that you can share?  I'm primarily a Java developer, so I'm not real sure how to test the Specs2 part.

Thanks,
Ben

WhyMeLord

unread,
Sep 10, 2013, 12:56:22 AM9/10/13
to play-fr...@googlegroups.com
Hi Ben,

I just did a test. With 2.1.4 RC2, below is the test class with a simple test method, not a crud. Is it because I am using Spring ? Isn't is possible to use Spring test with play2 ? Thanks alot.

@ContextConfiguration(classes = {BeansConfig.class, DataConfig.class})
public class ApplicationTest extends AbstractTransactionalJUnit4SpringContextTests {

    @Test
    public void simpleCheck() {
        int a = 1 + 1;
        assertThat(a).isEqualTo(2);

Ben McCann

unread,
Sep 10, 2013, 9:04:46 PM9/10/13
to play-fr...@googlegroups.com
I just tried @RunWith(MockitoJUnitRunner.class) and that worked for me, so it looks like @RunWith works under at least some circumstances. I've attached my ApplicationTest.java from the test that I tried.

There shouldn't be any problem with Spring. I've never tried Spring, but I use Guice which is very similar without any problems. If you're still having difficulty I would recommend making a test case that's as simple as possible and creating a bug with the example app attached. The Play team is very good about fixing bugs if you file them (I've filed almost 100 at this point, which I wouldn't keep doing if they weren't getting fixed! :-)

-Ben
ApplicationTest.java

Ben McCann

unread,
Sep 12, 2013, 1:39:09 PM9/12/13
to play-fr...@googlegroups.com
Any chance you can create a very simple sample app to reproduce this? I just saw someone else on the mailing list complaining about it and would really love to get it fixed, but my attempt to reproduce it was not successful. As long as we can easily reproduce it, then I am sure it will be fixed.
To unsubscribe from this group and all its topics, send an email to play-framework+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Byron Weber Becker

unread,
Sep 12, 2013, 6:01:21 PM9/12/13
to play-fr...@googlegroups.com
I also noted tests running twice.  I was trying to use ScalaTest and assumed it was interaction between Specs2 and ScalaTest.  As I recall, it went away when I renamed class files from XxxxTest to XxxxSpec.

Byron

Ben McCann

unread,
Sep 13, 2013, 1:14:13 AM9/13/13
to play-fr...@googlegroups.com
Byron, if you can send a simple example app, I'm sure the team would be happy to fix the issue

WhyMeLord

unread,
Sep 13, 2013, 8:47:04 PM9/13/13
to play-fr...@googlegroups.com

Ben McCann

unread,
Sep 13, 2013, 9:17:56 PM9/13/13
to play-fr...@googlegroups.com
Awesome! Thanks!!  I'm guessing this is probably a bug with either sbt or junit-interface (both of which Play depends on), so hopefully I'll get a chance soon to test that and file a bug with them as well if that's true.


--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/4Fz5TsOKPio/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

EECOLOR

unread,
Sep 21, 2013, 4:09:41 AM9/21/13
to play-fr...@googlegroups.com
Tests running twice is probably caused by the fact that you test class ends with the name `Test`. Apparently there are two mechanisms to find tests, where one is looking for tests that have a name ending in `Test`.


Erik
Reply all
Reply to author
Forward
0 new messages