gpt4 book ai didi

scala - sbt 无法执行 JUnit 测试

转载 作者:行者123 更新时间:2023-12-02 01:23:20 25 4
gpt4 key购买 nike

我正在尝试执行 JUnit 测试

sbt test

sbt clean test

测试失败并出现错误:

[info] Updating {file:/D:/sbt_projects/hello-word-ec/}hello-word-ec...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 2 Scala sources to D:\sbt_projects\hello-word-ec\target\scala-2.10\test-classes...
[error] D:\sbt_projects\hello-word-ec\src\test\scala\Test1.scala:1: object junit is not a member of package org
[error] import org.junit.Test
[error] ^
[error] D:\sbt_projects\hello-word-ec\src\test\scala\Test1.scala:3: not found: type Test
[error] @Test
[error] ^
[error] D:\sbt_projects\hello-word-ec\src\test\scala\Test2.scala:1: object junit is not a member of package org
[error] import org.junit.Test
[error] ^
[error] D:\sbt_projects\hello-word-ec\src\test\scala\Test2.scala:2: object junit is not a member of package org
[error] import org.junit.BeforeClass
[error] ^
[error] D:\sbt_projects\hello-word-ec\src\test\scala\Test2.scala:6: not found: type BeforeClass
[error] @BeforeClass
[error] ^
[error] D:\sbt_projects\hello-word-ec\src\test\scala\Test2.scala:12: not found: type Test
[error] @Test
[error] ^
[error] 6 errors found
[error] (test:compileIncremental) Compilation failed
[error] Total time: 1 s, completed Jul 28, 2016 6:10:04 PM

我的build.sbt文件内容

name := "sbt junit test project"
version := "1.0"
scalaVersion := "2.10.5"
libraryDependencies += "com.novocode" % "junit-interface" % "0.8" % "test->default"
libraryDependencies += "junit" % "junit" % "4.12" % Test
EclipseKeys.withSource := true

文件 %USERDIR%.sbt\0.13\plugins\build.sbt 看起来像

resolvers += Classpaths.typesafeResolver
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")

最佳答案

否则将 build.sbt 放在根项目文件夹中 sbt clean看不到 build.sbt 和下载依赖项。最初 build.sbt 位于 <project root>\project\文件夹

关于scala - sbt 无法执行 JUnit 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38640566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com