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.

543 questions
31
votes
3 answers

How to run specifications sequentially

I want to create few specifications that interoperate with database. class DocumentSpec extends mutable.Specification with BeforeAfterExample { sequential def before() = {createDB()} def after() = {dropDB()} // examples //…
Jeriho
  • 6,779
  • 9
  • 39
  • 56
28
votes
1 answer

Specs2: Ignore specification with a message?

I need to put one of my test cases into a "pending" state. I would like to assing some sort of message to it that can be displayed on the output when running the test, something like JUnit with @Ignore("Pending: issue #1234 needs to be fixed"). Is…
rlegendi
  • 9,744
  • 2
  • 35
  • 47
27
votes
5 answers

How to force Logger.debug output in Play! framework specs2 tests?

By default all Logger output, visible when an application is running, is mute when the application is tested. How to force the debugs, infos etc. to be shown in the specs2 reports?
Rajish
  • 6,525
  • 3
  • 31
  • 49
26
votes
5 answers

Parallel execution of tests

I've noticed that SBT is running my specs2 tests in parallel. This seems good, except one of my tests involves reading and writing from a file and hence fails unpredictably, e.g. see below. Are there any better options than setting all tests to…
Pengin
  • 4,468
  • 5
  • 32
  • 60
17
votes
6 answers

How to test methods that return Future?

I'd like to test a method that returns a Future. My attempts were as follows: import org.specs2.mutable.Specification import scala.concurrent.ExecutionContext.Implicits.global import scala.util.{Failure, Success} class AsyncWebClientSpec extends…
jaksky
  • 3,073
  • 3
  • 31
  • 65
16
votes
1 answer

How do you run only a single Spec2 specification with SBT?

If you have 2 tests defined in your SBT project: class Spec1 extends Specification { def is = "Tests for specification 1" ^ p ^ "Test case 1" ! todo ^ end } and class Spec2 extends Specification { def is = "Tests for…
Jack
  • 15,582
  • 17
  • 86
  • 162
16
votes
4 answers

Make ScalaCheck tests deterministic

I would like to make my ScalaCheck property tests in my specs2 test suite deterministic, temporarily, to ease debugging. Right now, different values could be generated each time I re-run the test suite, which makes debugging frustrating, because you…
Robin Green
  • 29,408
  • 13
  • 94
  • 178
15
votes
7 answers

running multiple tests within the same FakeApplication() in play 2.0 scala

I am trying to learn the unit tests in Play scala, but I am running into some issues. I am trying to run several tests on my models layer like this: "User Model" should { "be created and retrieved by username" in { …
wfbarksdale
  • 6,962
  • 11
  • 60
  • 87
14
votes
4 answers

BDD in Scala - Does it have to be ugly?

I've used lettuce for python in the past. It is a simple BDD framework where specs are written in an external plain text file. Implementation uses regex to identify each step, proving reusable code for each sentence in the specification. Using…
tiagoboldt
  • 2,336
  • 1
  • 22
  • 30
13
votes
1 answer

How to assert the type of an object, in specs2

In a specs2 test, how to validate the type of the return value of a function? Say, the function: trait P trait C1 extends P trait C2 extends P def test(n:Int): P = if(n%2==0) new C1 else new C2 Test: "test" should { "return C1 when n is even"…
Freewind
  • 177,284
  • 143
  • 381
  • 649
13
votes
4 answers

Execute code before and after specification

I have simple specification with several cases in it: class MySpec extends Specification { "Something" should { "case 1" in { ... } "case 2" in { ... } } } Now I need to start application, run all cases, and…
lambdas
  • 3,818
  • 2
  • 25
  • 52
13
votes
5 answers

Play! framework: customize which tests are run

I have a Play! 2 for Scala application, and I am using Specs2 for tests. I can run all tests with the test command, or a particular specification with test-only MyParticularSpec. What I would like to do is mark some particular specifications, or…
Andrea
  • 19,377
  • 21
  • 107
  • 177
12
votes
2 answers

How to stub a method call with an implicit matcher in Mockito and Scala

My application code uses AService trait AService { def registerNewUser (username: String)(implicit tenant: Tenant): Future[Response] } to register a new user. Class Tenant is a simple case class: case class Tenant(val vstNumber:String, val…
simou
  • 2,277
  • 3
  • 22
  • 37
12
votes
1 answer

How to run all Specs2 tests under IntelliJ IDEA?

In my Scala project, my Specs2 tests are structured as follows: src/test/scala -> my.package ---> my.package.sub1 ------> SomeTest1 ------> SomeTest2 ---> my.package.sub2 ------> SomeTest3 I'm using SBT to build all of this, and I can use sbt test…
DCKing
  • 4,053
  • 2
  • 23
  • 41
12
votes
3 answers

Play Framework Testing using MultipartFormData in a FakeRequest

I am currently in the process of writing some Specs2 tests for may Play Framework 2.2.x application which accepts MultipartFormData submissions as part of it's function. I have successfully written other tests with text and JSON bodies using the…
qt.cls
  • 133
  • 1
  • 5
1
2 3
36 37