I have a list of files exampleProblems
, to each of which I want to apply a method and check that it doesn't throw an exception. The problem is that I don't get a good failure message from Specs2. I need to find out which element caused the problem. I already tried adding an aka
, but with no success.
Here is the code:
def is: Fragments =
"parse all example uai files" ! (exampleProblems must contain((p: String) => {
Problem.parseUAIProblem(ClassLoader.getSystemResourceAsStream(p)).aka(p) must throwAn[Exception].not
}).forall)
And here is the message I'm getting:
java.lang.Exception: There is 1 failure Got the exception java.lang.IllegalArgumentException: requirement failed: variables are not ordered increasingly
at vultura.fastfactors.UAIParserTest$$anonfun$is$1$$anonfun$apply$1.apply(UAIParserTest.scala:24) at vultura.fastfactors.UAIParserTest$$anonfun$is$1$$anonfun$apply$1.apply(UAIParserTest.scala:24)
This means that the throwA[E]
matcher should be improved to display the expectable description when using aka
. I'll fix this but as a work-around you can write:
class TestSpec extends Specification { def is =
"parse all example uai files" ! {
Seq("a", "b") must contain { (p: String) =>
s"$p is ok" ==> { { sys.error("bang"); p} must not (throwAn[Exception]) }
}.forall
}
}
This displays:
[info] x parse all example uai files
[error] There is 1 failure
[error] a is not ok because Got the exception java.lang.RuntimeException: bang