Questions tagged [specs2]

Executable software specification tool that specifies behaviour both at the class and application level using Scala.

specs2 is a library for writing executable software specifications in Scala.

547 questions
7
votes
3 answers

How do I match a thrown Exception's message?

The specs2 Matchers guide states: throwA[ExceptionType](message = "boom") additionally checks if the exception message is as expected But when I use this, the message is apparently matched on the entire stacktrace instead of only the exception…
Meredith
  • 3,928
  • 4
  • 33
  • 58
7
votes
2 answers

Play Famework 2 - Scala - Start one application for test-suite

I've been following the Scala testing examples using Specs2 from the official Play documentation. I notice that they use WithApplication to start up a fake application to test against, with clode like the following: "something" should { "do X"…
user131441
7
votes
1 answer

Integrate Specs2 results with Jenkins

I want to integrate the Specs2 test results with Jenkins. I was added the below properties in sbt: resolver: "maven specs2" at "http://mvnrepository.com/artifact" libraryDependencies: "org.specs2" %% "specs2" %…
user2731619
  • 75
  • 1
  • 4
7
votes
2 answers

JVM memory settings for specs2

SBT keeps running out of memory on some of my bigger acceptance style tests using specs2 and spray-testkit. I have 10 gigs or RAM available and currently I start SBT (using the SBT extras script) with MaxPermSize at 512m, Xms at 1024m and Xmx at…
Jack
  • 16,506
  • 19
  • 100
  • 167
7
votes
1 answer

How can I skip a "should" block/fragment in specs2?

Suppose I have a specs2 specification defined in the "unit" style as follows: import org.specs2.mutable class MyClassSpec extends mutable.Specification { "myMethod" should { "return positive values" in { MyClass.myMethod must…
Kevinoid
  • 4,180
  • 40
  • 25
6
votes
1 answer

Test HttpErrorHandler with scalates/specs2 in Play Framework 2.4.2

I have implemented my own HttpErrorHander in Play Framework 2.4.2 and it functions very well, but now I want to be able to test with "Fake Actions" that intentionally throw Exceptions. I have tried in scalatest and specs2 import…
maloku
  • 153
  • 1
  • 7
6
votes
1 answer

How can I reduce the number of test cases ScalaCheck generates?

I'm trying to solve two ScalaCheck (+ specs2) problems: Is there any way to change the number of cases that ScalaCheck generates? How can I generate strings that contain some Unicode characters? For example, I'd like to generate about 10 random…
Zaphod
  • 1,387
  • 2
  • 17
  • 33
6
votes
0 answers

Stacktraces on user instantiated exceptions in Specs2 output

In our tests, we make extensive use of stubs, some of which create and throw exceptions. I'm finding that just instantiating an exception, is causing a stacktrace to show up when our tests run. This means that there's a large amount of unnecessary…
6
votes
3 answers

How to set up SBT build to return zero exit code on test failure for Jenkins?

When I am running my Specs2 tests in Jenkins via SBT, then the build is marked as a failure as soon as one test fails. Since Jenkins usually distinguishes between failure to build and test failures, I want to change this. I know that the build…
ziggystar
  • 28,410
  • 9
  • 72
  • 124
6
votes
2 answers

How to use playframework 2.3 with specs2 2.4 instead of specs2 2.3.x

Recently, specs2 was updated to version 2.4, which uses scalaz 7.1 instead of 7.0.x now. Once I update my specs2 dependency in my play! 2.3 project to use version 2.4, all tests fail with the following exception: [error] Uncaught exception when…
ingenue
  • 118
  • 2
  • 6
6
votes
1 answer

How to mock function returning AnyVal with Mockito in Scala / Specs2?

I would like to stub a function returning AnyVal using Mockito in Scala (Specs2 to be precise), but it doesn't seam to work: import org.specs2.mutable._ import org.specs2.mock._ case class V(s: String) extends AnyVal class A { def f: V = new…
6
votes
1 answer

How do I create a POST request with form field content with Spray?

I've got a Spray service that expects a POST with certain form fields filled out. I'm trying to work out how to create an appropriate POST in my test spec in order to test this. What I have so far Post("/customer") ~> sealRoute(myRoute) ~> check…
Ren
  • 3,395
  • 2
  • 27
  • 46
6
votes
1 answer

Using Akka TestKit with Specs2

I'm trying to craft a specs2 test using Akka's TestKit. I'm stuck on a persistent compile error I can't figure out how to resolve, and I'd appreciate suggestions. The compile error is: TaskSpec.scala:40: parents of traits may not have…
dr.
  • 247
  • 1
  • 5
  • 13
6
votes
1 answer

Play modules test & FakeApplication

I would like to know what's the best way to run specs2 tests on a PlayFramework module and be able to simulate it running. My module contains some routes in a file named mymodule.routes In my apps I integrate them by adding the following line in my…
Roch
  • 21,741
  • 29
  • 77
  • 120
6
votes
1 answer

How do I verify invokations with specific string matchers in Specs2 with Mockito

I have a test along these lines: httpClient.post(anyString, anyString) returns (first, second) //do my thing there were two(httpClient).post(anyString, anyString) This works fine, but I want to verify that the first call passes a different body…
iwein
  • 25,788
  • 10
  • 70
  • 111