specs2

How to run all Specs2 tests under IntelliJ IDEA?

十年热恋 提交于 2019-12-08 15:31:41
问题 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 to run all tests in my package. I'd like to use IntelliJ IDEA's built-in Specs2 run configuration support. I point it to use all tests in my.package . Running this yields the error message Error running <run config name>: Not found suite class. It

Play specs with configuration break because “There is no started application”

白昼怎懂夜的黑 提交于 2019-12-08 15:27:29
问题 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 fast in case of a missing key, like the docs say. Now some of my tests that depend on configured objects are failing with a stacktrace that states: Caused by: java.lang.RuntimeException: There is no started application I assume this has to do with the

Play Slick exception in Specs “Task slick.backend.DatabaseComponent rejected from java.util.concurrent.ThreadPoolExecutor”

随声附和 提交于 2019-12-08 02:11:44
问题 I am getting a ThreadPoolException from Slick using Play when running my Spec tests, This is using Play 2.4.x, Slick 3, Specs 2? My test looks like: val jsonHeaders = FakeHeaders(Seq((CONTENT_TYPE, MimeTypes.JSON))) def fakeApp: FakeApplication = FakeApplication(additionalConfiguration = Map( "slick.dbs.default.driver" -> "slick.driver.H2Driver$", "slick.dbs.default.db.driver" -> "org.h2.Driver", "slick.dbs.default.db.url" -> "jdbc:h2:mem:test;MODE=PostgreSQL;DATABASE_TO_UPPER=FALSE" )) "Add

How to do setup/teardown in specs2 when using “in new WithApplication”

…衆ロ難τιáo~ 提交于 2019-12-07 11:48:12
问题 I am using Specs2 with play 2.2.1 built with Scala 2.10.2 (running Java 1.7.0_51). I have been reading about how to do setup/teardown with Specs2. I have seen examples using the "After" trait as follows: class Specs2Play extends org.specs2.mutable.Specification { "this is the first example" in new SetupAndTeardownPasswordAccount { println("testing") } } trait SetupAndTeardownPasswordAccount extends org.specs2.mutable.After { println("setup") def after = println("teardown ") } This works fine,

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

喜你入骨 提交于 2019-12-07 10:03:21
问题 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 strings that include both alphanumeric and Unicode characters. This code, however, always generates 100 random strings, and they are strictly alpha character based: "make a random string" in { def stringGenerator = Gen.alphaStr.suchThat(_.length < 40)

Mockito stubbing method with value class argument fails with NullPointerException

谁说我不能喝 提交于 2019-12-07 09:54:59
问题 Using typed value classes as IDs is a common pattern in Scala. However, it seems Mockito has an issue when stubbing methods that take value classes as arguments. In the example below, the first stub, with an actual value works just fine, but the second one, that uses an argument matcher throws NullPointerException. The only reference to this I've found is this question but the solution shown there does not work. Anyone knows a solution to this, or a work-around? Versions are: org.mockito

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

霸气de小男生 提交于 2019-12-06 19:31:33
问题 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 回答1: You can use test { //makes the standard streams (err and out) visible at console when running tests testLogging.showStandardStreams = true } But this logs stdout at the info level so you need to run gradle -i to see it (it seems this will be fixed in 1.1:

org.specs2.mock.Mockito matchers are not working as expected

我是研究僧i 提交于 2019-12-06 16:02:10
Here is the code I am trying to run: import org.specs2.mock.Mockito import org.specs2.mutable.Specification import org.specs2.specification.Scope import akka.event.LoggingAdapter class MySpec extends Specification with Mockito { "Something" should { "do something" in new Scope { val logger = mock[LoggingAdapter] val myVar = new MyClassTakingLogger(logger) myVar.doSth() there was no(logger).error(any[Exception], "my err msg") } } } When running this, I get the following error: [error] org.mockito.exceptions.misusing.InvalidUseOfMatchersException: [error] Invalid use of argument matchers! [error

Still can't run multiple tests against play FakeApp with Salat / Casbah

霸气de小男生 提交于 2019-12-06 08:10:08
问题 I thought I had fixed the problem temporarily, but it turns out I am still having problems. I am trying to create some specs2 tests for my models layer, I would like to insert some dummy object, and then run some queries to make sure data comes out as expected. Here is what my simple test looks like: class ModelSpec extends Specification { override def is = args(sequential = true) ^ super.is object FakeApp extends FakeApplication() running(FakeApp){ println("set up database") val newUser =

Play Slick exception in Specs “Task slick.backend.DatabaseComponent rejected from java.util.concurrent.ThreadPoolExecutor”

£可爱£侵袭症+ 提交于 2019-12-06 06:29:30
I am getting a ThreadPoolException from Slick using Play when running my Spec tests, This is using Play 2.4.x, Slick 3, Specs 2? My test looks like: val jsonHeaders = FakeHeaders(Seq((CONTENT_TYPE, MimeTypes.JSON))) def fakeApp: FakeApplication = FakeApplication(additionalConfiguration = Map( "slick.dbs.default.driver" -> "slick.driver.H2Driver$", "slick.dbs.default.db.driver" -> "org.h2.Driver", "slick.dbs.default.db.url" -> "jdbc:h2:mem:test;MODE=PostgreSQL;DATABASE_TO_UPPER=FALSE" )) "Add new group" in new WithApplication(FakeApp.fakeApp){ val vg = new ViewGroup(0, "Test", "Tests") val add