EDIT:如果文件位于,则有效src/test/scala/tests/
但不在src/main/scala/mypackage/
. Why?
我已经尝试过人们遇到几乎相同问题的主题的解决方案,但没有一个有效。
有关详细信息,我在 build.sbt 中有这个:
libraryDependencies ++= Seq(
...
"org.scalatest" % "scalatest_2.10" % "2.2.1" % "test",
...
在 Intellij 中,我有一堂课:
import org.scalatest.{BeforeAndAfterAll, Suite}
with {BeforeAndAfterAll, Suite}
红色,所以我猜找到了 scalatest
sbt 包也不起作用:
对象 scalatest 不是包 org 的成员 [错误] 导入
org.scalatest. {之前和之后,组曲}
我已经尝试过这个:
- sbt 干净更新
- 重启+使intellij的缓存失效
- 删除 .idea/ 并重新导入
- libraryDependencies += "org.scalatest" % "scalatest_2.10" % "2.0" % "test" 而不是 ogf 实际的
- 我键盘上的神奇仪式
没有任何效果
有任何想法吗?
你应该看看SBT项目结构 http://www.scala-sbt.org/0.13/docs/Directories.html#Source+code:
src/
main/
resources/
<files to include in main jar here>
scala/
<main Scala sources>
java/
<main Java sources>
test/
resources
<files to include in test jar here>
scala/
<test Scala sources>
java/
<test Java sources>
你的 scala 测试应该进行src/test/scala/
.
如果您确实想在 main 中使用 scalatest(并且您知道自己要做什么),请尝试以下操作:
"org.scalatest" % "scalatest_2.10" % "2.2.1",
在你原来的build.sbt
,“test”是配置,这意味着 scalatest 将仅位于测试类路径上,并且主要源不需要它。这对于库来说通常是一个很好的实践,因为您的用户通常不需要您的测试依赖项来使用您的库(ref http://www.scala-sbt.org/0.13/docs/Testing.html).
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)