使用Scalatest从打包的二进制文件执行PlaySpec测试

时间:2017-02-23 09:14:57

标签: scalatest

我有一个功能测试的Play项目。我能够用SBT执行测试。他们正在使用浏览器针对已部署的应用程序进行测试,即with OneServerPerSuite with OneBrowserPerSuite ...

我没有使用SBT /从源代码执行测试,而是想编译&打包它们并从二进制文件运行。但是,如果我打包测试类(在SBT中使用test: package)并运行它们,则不会执行任何测试,例如如果我将所有依赖项复制到libs,包括scala,ScalaTest等:

$ java -cp target/scala-2.10/myproject-acceptance_2.10-1.0-tests.jar:libs/* org.scalatest.tools.Runner -o -u results
Discovery starting.
Discovery completed in 20 milliseconds.
Run starting. Expected test count is: 0
DiscoverySuite:
Run completed in 57 milliseconds.
Total number of tests run: 0
Suites: completed 1, aborted 0
Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0

我无法运行任何测试。我为scala测试运行器尝试了-s-m-w-q次切换。我可以通过指定后缀(例如“MyWebappLogin”)来获得最接近的测试

$ ... Runner -o -u results -q Login
Suites: completed 1, aborted 0
Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0

测试本身基于Play - Scala Functional Testing

的指南

这是我正在尝试的登录测试(MyWebappLogin.scala):

class MyWebappLogin extends PlaySpec with OneServerPerSuite with OneBrowserPerSuite with PhantomJSFactory with MustMatchers {

  val loginPage = new WebappLoginPage() //extends org.scalatest.selenium.Page with WebBrowser

  "The Login Page" must {
    "Render with title" in {
      go to (loginPage)
      pageTitle mustEqual "Please Log In"
    }
  }
}

如何让测试与ScalaTest跑步者一起运行?

0 个答案:

没有答案