【问题标题】:sbt not recognizing testsbt 不识别测试
【发布时间】:2012-12-04 04:24:00
【问题描述】:

我很难让 sbt(0.12.1 版)识别 src/test/scala 中的任何测试。

我已经尝试过 JUnit 样式测试和 scalatest 样式测试,但没有 avial

让事情变得简单

  • 我已将测试移至根包 (src/test/scala)

  • 我在 build.sbt 中包含了 org.scalatest 和 junit-interface libraryDependencies ++= 列表( "org.scalatest" %% "scalatest" % "1.8" % "test", “com.novocode”%“junit-interface”%“0.8”%“test->default” )

  • 我已使测试尽可能简单:

  • 最大规模的例子

    导入 org.scalatest.FunSuite 导入 scala.collection.mutable.Stack

    类 ExampleSuite 扩展 FunSuite {

    test("数学仍然有效") { 断言(1+1 == 2) } }

  • junit 测试示例: 导入 org.junit.Assert._ 导入 org.junit.Test

    类 SimpleTest {

    @测试 def testPass() { assertEquals(1+1, 2) }

    }

  • 我的测试结构是: src/test/scala

    ├── FunSuiteExample.scala

    └── SimpleTest.scala

我错过了什么?

【问题讨论】:

  • sbt test 的控制台输出是什么?

标签: testing sbt junit4


【解决方案1】:

根据以下说明:

https://github.com/szeiger/junit-interface

修改build.sbt

  • 从 build.sbt 中删除了 "junit" % "junit" % "4.10" % "test"
  • 已添加"com.novocode" % "junit-interface" % "0.11" % "test"

将测试放在 src/test/scala 中

import org.junit._
import org.junit.Assert._


class SimpleTeset {

  @Test
  def testTrue() {
    assertEquals(1+1, 2)
  }
}

【讨论】:

  • 适用于 SBT 1.1.4
猜你喜欢
  • 1970-01-01
  • 2012-11-04
  • 2015-12-20
  • 2014-02-20
  • 1970-01-01
  • 1970-01-01
  • 2012-06-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多