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
12
votes
3 answers

Scalatest or specs2 with multiple test cases

In TestNg and Java, we can run multiple test cases using DataProvider, and this runs as separate tests, meaning execution of a test isn't stopped on failure. Is there an analogue for ScalaTest or Specs/Specs2?
user44242
  • 1,168
  • 7
  • 20
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,253
  • 2
  • 28
  • 43
11
votes
1 answer

How to show custom failure message in Specs2 (Scala)?

For example, for code like this: myNum must beEqualTo("SOME INTERESTING TEXT") The message will be like the following: java.lang.Exception: ArrayBuffer() doesn't have size 1 but size 0 Is there an elegant way to get customised message displayed…
Johnny
  • 14,397
  • 15
  • 77
  • 118
11
votes
3 answers

how to make scalatest generate html report through sbt

The way to do this for specs2 based test in sbt is (testOptions in Test) += Tests.Argument(TestFrameworks.Specs2, "html") but how about scalatest? I've done lots of Google search, but cannot find a good explanation/solution.
Sheng
  • 1,697
  • 4
  • 19
  • 33
11
votes
2 answers

How do I set the test output to console instead of html in gradle for specs2

I'm using specs2/scala for unit tests and using gradle to build. By default the unit-test output goes to a html file. I would like to have the output go directly to stdout (just like sbt). Anyone know the magic incantation? thanks wing
wing
  • 171
  • 1
  • 5
11
votes
1 answer

Play specs with configuration break because "There is no started application"

I externalized some strings to HOCON, on application.conf. I'm accessing the configuration values like this: import play.api.Play.current import play.api.Play.configuration configuration.getString("foo.bar").get() As early as possible, to fail…
Pablo Fernandez
  • 103,170
  • 56
  • 192
  • 232
10
votes
2 answers

How to use Specs2 with Scalacheck to automate testing of String arguments?

The rewritten specs2 testing framework for Scala integrates automated testing with scalacheck. The examples given in the specs2 documentation on how to use scalacheck together with specs2 either use integers or more complicated custom generators as…
Steffen
  • 8,033
  • 1
  • 28
  • 34
10
votes
2 answers

Scala: How to test methods that call System.exit()?

I have been developing a command-line tool which calls System.exit() (don't want to use exceptions instead of) on certain inputs. I am familiar with Java: How to test methods that call System.exit()? and its the most elegant approach. Unfortunately,…
sergiusz.kierat
  • 139
  • 1
  • 10
10
votes
1 answer

specs/scalatest interaction issue in Play app

I am having a problem I really can't explain... It is in isolation in the project at https://github.com/betehess/play-scalatest. When I run test, sbt gets stuck for a while and then throws this exception: > test [error] Uncaught exception when…
betehess
  • 839
  • 4
  • 19
10
votes
8 answers

Writing a test case for file uploads in Play 2.1 and Scala

I found the following question/answer: Test MultipartFormData in Play 2.0 FakeRequest But it seems things have changed in Play 2.1. I've tried adapting the example like so: "Application" should { "Upload Photo" in { running(FakeApplication()) { …
djsumdog
  • 2,560
  • 1
  • 29
  • 55
10
votes
1 answer

How to run an embedded elastic search instance for testing

I'm working in a setup that has an embedded elastic search instance for unit testing purposes, but when I run the tests continuously with sbt (~test-only ) the system becomes increasingly unstable until it freezes and has to be killed with…
iwein
  • 25,788
  • 10
  • 70
  • 111
9
votes
3 answers

How can I roll back an integration test with Slick 3 + Specs2?

I want to write some integration tests for a service that runs slick and then clean a postgresql database up afterward up by rolling back a transaction, but I don't see a way to do it. I understand that I can test DBIO objects which have been…
mikebridge
  • 4,209
  • 2
  • 40
  • 50
9
votes
1 answer

Why is this specs2 test using Mockito passing?

Suppose I had this interface and class: abstract class SomeInterface{ def doSomething : Unit } class ClassBeingTested(interface : SomeInterface){ def doSomethingWithInterface : Unit = { Unit } } Note that the doSomethingWithInterface…
mushroom
  • 6,201
  • 5
  • 36
  • 63
9
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
  • 505
  • 4
  • 15
9
votes
5 answers

Play 2.0 FakeApplication setup with test configuration

I have a specs2 test which uses a FakeApplication and an embedded mongodb database. def inMemoryMongoDatabase(name: String = "default"): Map[String, String] = { val dbname: String = "play-test-" + scala.util.Random.nextInt Map( …
cmacher
  • 181
  • 1
  • 1
  • 7
1
2
3
36 37