mardi 21 avril 2015

ScalaTest Plus not recognizing tests

I've been tasked to update and write a series of tests on an app in Scala Play, a language and framework I'm unfamiliar with. Part of what I'd like to do is integrate the ScalaTestPlus library. To get started I have been following the following tutorial:

http://ift.tt/1Iy9Spj

Unfortunately I am not getting very far. I have added a new unit test file to the tests folder:

import org.scalatestplus.play._

class StackSpec extends PlaySpec {

  "A Test" must {
    "pass" in {
      assert(1 == 1)
    }
    "Fail" in {
      assert(1 != 1)
    }
  }
}

and I have updated my build.sbt to include the scalatestplus library

  "org.scalatestplus" % "play_2.37" % "1.2.0" % "test"//,

Using Activator, I am trying to run my test file with test-only. Everything compiles without errors, but activator is not finding any tests

[info] No tests were executed.

I don't believe the issue is with activator, since I can run old test files (from the previous engineer) using the test and test-only commands. A quick sample of one of the previous (working) test files:

import java.util.concurrent.TimeUnit
import com.sun.xml.internal.bind.v2.TODO
import scala.collection.JavaConverters._
import controllers.Application
import models.{Item, PriorityBucket}
import play.api.test._

class WebSpec extends PlaySpecification {

  "Home page" should {
    "do something" in new WithSeleniumDbData(TestUtil.testApp) {
      Redacted.deleteAll()

      val ObId = TestUtil.create(Some(PriorityBucket.Low),
          Some(Application.ENGLISH))
      val item = Item.find(ItemId).get

      browser.goTo("/")
      browser.await().atMost(2, 
          TimeUnit.SECONDS).until(Selectors.all_obs).isPresent
    }

Any ideas where I've gone astray? Thanks in advance for the help!

I am using scala 2.11 I am using play 2.3.7

EDIT: Possibly relevant, I switched the extension from PlaySpec to FlatSpec and saw the following error when compiling:

SampleSpec.scala:10: value in is not a member of String
[error]     "pass" in {

I made sure to import FlatSpec as well, which has me a bit confused--is FlatSpec a member of ScalaTest but not a member of ScalaTestPlus, I don't see why else the compilation would fail.

UPDATE: To further investigate the issue I spun up a brand new Play app and copied over my sample test. After some tooling around with versions I've been able to get my test to run on the activator test command with the rest of the suite. Unfortunately, any other commands like test-only are still returning no tests run.

Aucun commentaire:

Enregistrer un commentaire