2016-07-28 113 views
2

我試圖執行JUnit測試SBT無法執行JUnit測試

SBT測試

SBT乾淨的測試

測試失敗,錯誤:

[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%名.bst \ 0.13 \插件\ build.sbt看起來像

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

回答

1

根項目文件夾認沽build.sbt否則sbt clean無法看到build.sbt和下載的依賴。最初build.sbt位於<project root>\project\文件夾中