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

Creating a Specs2 matcher in a modular way

I have functions A => Double. I want to check whether two such functions give the same results (up to a tolerance, using the existing beCloseTo matcher) for a given set of values. I want to be able to write: type TF = A => Double (f: TF) must…
ziggystar
  • 28,410
  • 9
  • 72
  • 124
8
votes
4 answers

How to specify different application.conf for specs2 tests?

I have an IntelliJ IDEA project in Scala and started adding org.specs2 tests. I am having trouble finding out how to put in an application.conf file that will be used by the tests. I have tried doing the following: test resources …
user2916547
  • 1,963
  • 5
  • 17
  • 21
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,458
  • 2
  • 18
  • 31
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
  • 344
  • 3
  • 13
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
  • 7,129
  • 9
  • 41
  • 57
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
  • 1,955
  • 3
  • 22
  • 30
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,557
  • 4
  • 33
  • 63
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,189
  • 2
  • 11
  • 24
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
  • 51,734
  • 32
  • 149
  • 189
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
  • 681
  • 4
  • 19
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,899
  • 1
  • 18
  • 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
  • 80,077
  • 70
  • 264
  • 372
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
  • 2,097
  • 3
  • 17
  • 26
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,633
  • 3
  • 35
  • 84
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
  • 527
  • 4
  • 15
1 2
3
36 37