Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ScalateTest Plus不识别测试_Scala_Playframework_Scalatest - Fatal编程技术网

ScalateTest Plus不识别测试

ScalateTest Plus不识别测试,scala,playframework,scalatest,Scala,Playframework,Scalatest,我的任务是在Scala Play中更新和编写一系列测试,Scala Play是一种我不熟悉的语言和框架。我想做的部分工作是集成ScalaTestPlus库。为了开始,我一直遵循以下教程: 不幸的是,我没走多远。我已将新的单元测试文件添加到“测试”文件夹: import org.scalatestplus.play._ class StackSpec extends PlaySpec { "A Test" must { "pass" in { assert(1 ==

我的任务是在Scala Play中更新和编写一系列测试,Scala Play是一种我不熟悉的语言和框架。我想做的部分工作是集成ScalaTestPlus库。为了开始,我一直遵循以下教程:

不幸的是,我没走多远。我已将新的单元测试文件添加到“测试”文件夹:

import org.scalatestplus.play._

class StackSpec extends PlaySpec {

  "A Test" must {
    "pass" in {
      assert(1 == 1)
    }
    "Fail" in {
      assert(1 != 1)
    }
  }
}
我已经更新了build.sbt以包含scalatestplus库

  "org.scalatestplus" % "play_2.37" % "1.2.0" % "test"//,
使用Activator,我尝试仅使用test运行测试文件。一切编译都没有错误,但activator找不到任何测试

[info] No tests were executed.
我认为问题不在于activator,因为我可以使用test和test-only命令运行旧的测试文件(来自以前的工程师)。先前(工作)测试文件之一的快速示例:

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
    }
知道我在哪里误入歧途了吗?提前感谢您的帮助

我正在使用scala 2.11 我正在使用play 2.3.7

编辑:可能相关,我将扩展从PlaySpec切换到FlatSpec,并在编译时看到以下错误:

SampleSpec.scala:10: value in is not a member of String
[error]     "pass" in {
我还确保导入了FlatSpec,这让我有点困惑——FlatSpec是ScalaTest的成员,但不是ScalaTestPlus的成员,我不明白为什么编译会失败


更新:为了进一步调查这个问题,我开发了一个全新的Play应用程序,并复制了我的样本测试。在使用了一些版本的工具之后,我已经能够让我的测试与套件的其余部分一起在activator test命令上运行。不幸的是,像test only这样的任何其他命令仍然没有返回任何测试运行。

对于我遇到这个问题的后续命令…在这种情况下,类名必须与文件名相同,否则test only无法找到它。

尝试
导入org.junit.runner.\u
并添加
@RunWith(classOf[JUnitRunner])
到类中,不幸的是没有工作。导入org.junit.runner.RunWith和导入org.scalatest.junit.JUnitRunner时的结果相同