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
8
votes
1 answer

How to group tests using specs2?

I'm used to JUnit, in JUnit it is possible to group several tests (usually related to a class) just by defining these tests in a single file (class) and annotating them with @Test. Then, to run several of these tests, a TestSuite is created with…
Trylks
  • 1,300
  • 16
  • 28
8
votes
3 answers

scala spec2 I am Unable to create a test that uses must be_== and failure at the same time

I am new to Scala and Spec2. I would like to create the following test but I get an error from the compiler. Here is the test I would like to write import org.specs2.mutable._ import org.specs2.specification._ import org.specs2.matcher._ import…
shodz
  • 194
  • 2
  • 12
8
votes
1 answer

Fast test execution in a playframework fake application

Running tests as described here "Spec" should { "example" in new WithApplication { ... } } is unacceptably slow for me. This is because new WithApplication is starting and stoping framework at every example. Don't get me wrong, a framework…
Jeriho
  • 6,779
  • 9
  • 39
  • 56
8
votes
3 answers

Play 2.2 - specs2 - How to test futures in play 2.2?

my way of testing futures was using value1. I migrated to play2.2. I found out, my accustomed way to test is gone. @scala.deprecated("Use scala.concurrent.Promise instead.", "2.2") Any help would be greatly appreciated. Oliver
OliverKK
  • 485
  • 4
  • 15
8
votes
1 answer

Play Framework 2 scala specs2 mockito, how do I write a mocking unit test

So the play framework talks about having specs2 and specs2 having mockito I want to use mockito to write a test where the template that the controller invokes is a mockito mock. All the doc's I've found so far are java implementations where you call…
The Trav
  • 2,257
  • 3
  • 20
  • 27
8
votes
2 answers

Final clean up in specs2

I am writing a specs2 Unittest for my scala software. The execution is working well. The only problem I have, is that I need to clean up after all test are finished. I just cannot find any solution for that. Is there a way to execute some functions…
tgr
  • 3,309
  • 2
  • 30
  • 57
8
votes
3 answers

How can i skip a test in specs2 without matchers?

I am trying to test some db dependent stuff with specs2 in scala. The goal is to test for "db running" and then execute the test. I figured out that i can use orSkip from the Matcher class if the db is down. The problem is, that i am getting output…
Alebon
  • 1,169
  • 2
  • 11
  • 23
7
votes
1 answer

How do I run Scala + specs2 from the command line?

I'm a completely newbie Scala programmer, and I have no previous experience with Java; I come from ruby. I'm trying to run my first TDD sample program. I'm planning something very small, with maybe 5 or 6 tests. I'm trying to use the specs2 lib. I…
kikito
  • 48,656
  • 29
  • 134
  • 183
7
votes
2 answers

Configuring junitxml output for specs2 tests in sbt 0.10

How do I configure sbt 0.10 to use the junitxml option with specs2? The specs2 documentation says this is the way to do it using sbt 0.7.x: override def testOptions = super.testOptions ++ Seq(TestArgument("junitxml")) How do I say the same thing in…
Adam Pingel
  • 661
  • 4
  • 18
7
votes
1 answer

Create assembly jar that contains all tests in SBT project+subprojects

I have an interesting problem where I basically need to create a .jar (plus all of the classpath dependencies) that contains all of the tests of an SBT project (plus any of its subprojects). The idea is that I can just run the jar using java -jar…
mdedetrich
  • 1,809
  • 13
  • 29
7
votes
3 answers

Specs2: how to test a class with more than one injected dependency?

Play 2.4 app, using dependency injection for service classes. I found that Specs2 chokes when a service class being tested has more than one injected dependency. It fails with "Can't find a constructor for class ..." $ test-only…
Jonik
  • 74,291
  • 66
  • 249
  • 356
7
votes
0 answers

how to test action with multipart form data in play scala framework

I need an action method to receive file upload and I want to test this also. But my test is throwing error My action: def upload = Action.async(parse.multipartFormData) { request => val multipart = request.body val optFile =…
surenyonjan
  • 1,989
  • 2
  • 15
  • 25
7
votes
2 answers

specs2 -- Could not create an instance

testOnly play.api.weibo.StatusesShowBatchSpec [error] Could not create an instance of play.api.weibo.StatusesShowBatchSpec [error] caused by java.lang.Exception: Could not instantiate class play.api.weibo.StatusesShowBatchSpec: null [error] …
jilen
  • 5,190
  • 1
  • 29
  • 74
7
votes
1 answer

Canonical Example of how to test Akka Actor using Scala in Play Framework

Having created an Akka actor in Play Framework, I now want to test it. However I immediately hit a problem: The current Play Scala Testing page contains nothing about testing Actors and uses Specs2 for all examples I could find no actor test…
dnh
  • 451
  • 3
  • 13
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
  • 2,617
  • 3
  • 26
  • 55
1 2
3
36 37