我正在尝试使用 ant 作为构建系统的 ScalaTest。我正在尝试使用示例代码:
package se.uu.molmed.SandBoxScalaTest
import org.scalatest.FlatSpec
import org.scalatest.Tag
object SlowTest extends Tag("com.mycompany.tags.SlowTest")
object DbTest extends Tag("com.mycompany.tags.DbTest")
class TestingTags extends FlatSpec {
"The Scala language" must "add correctly" taggedAs(SlowTest) in {
val sum = 1 + 1
assert(sum === 2)
}
it must "subtract correctly" taggedAs(SlowTest, DbTest) in {
val diff = 4 - 1
assert(diff === 3)
}
}
我正在尝试使用以下 ant 目标运行它:
<!-- Run the integration tests -->
<target name="slow.tests" depends="build">
<taskdef name="scalatest" classname="org.scalatest.tools.ScalaTestAntTask">
<classpath refid="build.classpath" />
</taskdef>
<scalatest parallel="true">
<tagstoinclude>
SlowTests
</tagstoinclude>
<tagstoexclude>
DbTest
</tagstoexclude>
<reporter type="stdout" />
<reporter type="file" filename="${build.dir}/test.out" />
<suite classname="se.uu.molmed.SandBoxScalaTest.TestingTags" />
</scalatest>
</target>
它编译得很好,并运行套件,但不包括测试。我希望它在上面的代码中运行两个测试中的第一个。输出如下所示:
slow.tests:
[scalatest] Run starting. Expected test count is: 0
[scalatest] TestingTags:
[scalatest] The Scala language
[scalatest] Run completed in 153 milliseconds.
[scalatest] Total number of tests run: 0
[scalatest] Suites: completed 1, aborted 0
[scalatest] Tests: succeeded 0, failed 0, ignored 0, pending 0, canceled 0
[scalatest] All tests passed.
为什么会这样?任何帮助将非常感激。