bug when running tests

49 views
Skip to first unread message

benmccann

unread,
Feb 16, 2013, 2:38:41 PM2/16/13
to simple-b...@googlegroups.com
When I run a junit 4 test in Play Framework, the exception type is swallowed.  I think that this is an SBT issue.  Has anyone else noticed this?

E.g. in my test I throw a new IllegalArgumentException and the stack trace I get does not mention an IllegalArgumentException at all. This is very frustrating for debugging.

java.lang.RuntimeException: Tests unsuccessful
at scala.sys.package$.error(package.scala:27)
at scala.Predef$.error(Predef.scala:123)
at sbt.Tests$.showResults(Tests.scala:192)
at sbt.Defaults$$anonfun$testTasks$6.apply(Defaults.scala:296)
at sbt.Defaults$$anonfun$testTasks$6.apply(Defaults.scala:294)
at sbt.Scoped$$anonfun$hf4$1.apply(Structure.scala:580)
at sbt.Scoped$$anonfun$hf4$1.apply(Structure.scala:580)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:49)
at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:41)
at sbt.std.Transform$$anon$5.work(System.scala:71)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
at sbt.Execute.work(Execute.scala:238)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)

Thanks,
Ben

Mark Harrah

unread,
Feb 21, 2013, 8:07:18 PM2/21/13
to simple-b...@googlegroups.com
On Sat, 16 Feb 2013 11:38:41 -0800 (PST)
benmccann <benjamin...@gmail.com> wrote:

> When I run a junit 4 test in Play Framework, the exception type is swallowed<https://play.lighthouseapp.com/projects/82401-play-20/tickets/776-play-swallows-exception-type-in-tests>.
> I think that this is an SBT issue. Has anyone else noticed this?
>
> E.g. in my test I throw a new IllegalArgumentException and the stack trace
> I get does not mention an IllegalArgumentException at all. This is very
> frustrating for debugging.

What sbt version and can you provide a reproducible test case without Play?

-Mark
> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to simple-build-t...@googlegroups.com.
> To post to this group, send email to simple-b...@googlegroups.com.
> Visit this group at http://groups.google.com/group/simple-build-tool?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Ben McCann

unread,
Feb 21, 2013, 8:13:38 PM2/21/13
to simple-b...@googlegroups.com
sbt.version=0.12.2.  I haven't tried it outside of Play

Mark Harrah

unread,
Feb 21, 2013, 8:18:32 PM2/21/13
to simple-b...@googlegroups.com
On Thu, 21 Feb 2013 17:13:38 -0800
Ben McCann <b...@benmccann.com> wrote:

> sbt.version=0.12.2. I haven't tried it outside of Play

The only known test-related problem in 0.12.2 that I can remember is https://github.com/sbt/sbt/issues/653.

-Mark

Ben McCann

unread,
Feb 21, 2013, 9:18:03 PM2/21/13
to simple-b...@googlegroups.com
I'm trying to install sbt standalone to test this, but the sbt 12.2 download is telling me that it is sbt 0.12.0.  Is there a problem here?

Connecting to scalasbt.artifactoryonline.com (scalasbt.artifactoryonline.com)|23.20.223.55|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 981276 (958K) [application/octet-stream]
Saving to: `sbt.deb'

100%[===============================================================================================================================>] 981,276      599K/s   in 1.6s    

2013-02-21 18:15:53 (599 KB/s) - `sbt.deb' saved [981276/981276]

bmccann@bmccann-VirtualBox:~/src/sbt-test-first-line$ sudo dpkg -i sbt.deb 
Selecting previously unselected package sbt.
(Reading database ... 414490 files and directories currently installed.)
Unpacking sbt (from sbt.deb) ...
Setting up sbt (0.12.2-0.1-build-001) ...
Processing triggers for man-db ...
bmccann@bmccann-VirtualBox:~/src/sbt-test-first-line$ sbt
[info] Set current project to default-7a0e31 (in build file:/home/bmccann/src/sbt-test-first-line/)
> sbt-version
[info] 0.12.0


Ben McCann

unread,
Feb 21, 2013, 9:26:46 PM2/21/13
to simple-b...@googlegroups.com
Hmm, I added a project/build.properties and it fixed it. Extremely strange and unintuitive that it would use an older version by default though.
--
about.me/benmccann

Ben McCann

unread,
Feb 21, 2013, 9:40:10 PM2/21/13
to simple-b...@googlegroups.com
Ok, this happens outside of Play.  If you run sbt test it swallows the fact that an IllegalArgumentException caused the test to fail
sbt-test-first-line.zip

Mark Harrah

unread,
Feb 22, 2013, 8:08:29 AM2/22/13
to simple-b...@googlegroups.com
On Thu, 21 Feb 2013 18:40:10 -0800
Ben McCann <b...@benmccann.com> wrote:

> Ok, this happens outside of Play. If you run sbt test it swallows the fact
> that an IllegalArgumentException caused the test to fail

Thanks for the test case. The output that I see is:

[error] Test com.benmccann.example.BenTest.testGetName failed: sbt should show this
[error] at com.benmccann.example.BenTest.testGetName(BenTest.java:12)
[error] ...

(the ... is literal and not a placeholder)

This looks like intended junit-interface behavior:

https://github.com/szeiger/junit-interface/blob/master/src/main/java/com/novocode/junit/RichLogger.java#L71

I don't think there are more frames to show. Perhaps you mean the exception type should be printed or you are referring to:

[trace] Stack trace suppressed: run last test:test-only for the full output.

If the latter, this is just the stack trace for the exception thrown when tests fail. This has been fixed so that it isn't displayed (the trace isn't useful and the message might be confusing).

-Mark

>

Ben McCann

unread,
Feb 22, 2013, 11:38:16 AM2/22/13
to simple-b...@googlegroups.com
I mean the exception type should be printed. In this example it should say "IllegalArgumentException" somewhere on the screen. We've had multiple people on our team complaining that some things are really difficult to debug because you don't know what type of exception is thrown if you get an exception when running our tests.

Mark Harrah

unread,
Feb 22, 2013, 11:45:57 AM2/22/13
to simple-b...@googlegroups.com
On Fri, 22 Feb 2013 08:38:16 -0800
Ben McCann <b...@benmccann.com> wrote:

> I mean the exception type should be printed. In this example it should say
> "IllegalArgumentException" somewhere on the screen. We've had multiple
> people on our team complaining that some things are really difficult to
> debug because you don't know what type of exception is thrown if you get an
> exception when running our tests.

That is done by junit-interface:

https://github.com/szeiger/junit-interface/blob/master/src/main/java/com/novocode/junit/EventDispatcher.java#L47

-Mark

Ben McCann

unread,
Feb 22, 2013, 11:50:09 AM2/22/13
to simple-b...@googlegroups.com
Ok, I've filed a bug with junit-interface. It would be great to get this fixed for all sbt users


--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-build-t...@googlegroups.com.
To post to this group, send email to simple-b...@googlegroups.com.
Visit this group at http://groups.google.com/group/simple-build-tool?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply all
Reply to author
Forward
0 new messages