Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.NoClassDefFoundError:sbt/testing/Framework在执行ScalaTest测试时?_Scala_Sbt_Scalatest - Fatal编程技术网

java.lang.NoClassDefFoundError:sbt/testing/Framework在执行ScalaTest测试时?

java.lang.NoClassDefFoundError:sbt/testing/Framework在执行ScalaTest测试时?,scala,sbt,scalatest,Scala,Sbt,Scalatest,我使用ScalaTest作为我的测试框架 构建.sbt import com.typesafe.sbt.SbtStartScript name := "myproject" organization := "my.org" version := "0.1" scalaVersion := "2.11.0" //Define dependencies. These ones are only required for Test and Integration Test scopes. l

我使用ScalaTest作为我的测试框架

构建.sbt

import com.typesafe.sbt.SbtStartScript

name := "myproject"

organization := "my.org"

version := "0.1"

scalaVersion := "2.11.0"

//Define dependencies. These ones are only required for Test and Integration Test scopes.
libraryDependencies ++= Seq(
    "org.scalatest"   %% "scalatest"    % "2.1.7"   % "test,it",
    "org.scalacheck"  %% "scalacheck"   % "1.11.4"      % "test,it",
    "com.typesafe.akka" %% "akka-actor" % "2.3.3",
    "org.scala-lang" % "scala-swing" % "2.11.0-M7",
    "commons-io" % "commons-io" % "2.4"
)

// For Settings/Task reference, see http://www.scala-sbt.org/release/sxr/sbt/Keys.scala.html

// Compiler settings. Use scalac -X for other options and their description.
// See Here for more info http://www.scala-lang.org/files/archive/nightly/docs/manual/html/scalac.html 
scalacOptions ++= List("-feature","-deprecation", "-unchecked", "-Xlint")

// ScalaTest settings.
// Ignore tests tagged as @Slow (they should be picked only by integration test)
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-l", "org.scalatest.tags.Slow", "-u","target/junit-xml-reports", "-oD", "-eS")

//Style Check section 
org.scalastyle.sbt.ScalastylePlugin.Settings

org.scalastyle.sbt.PluginKeys.config <<= baseDirectory { _ / "src/main/config" / "scalastyle-config.xml" }

// Generate Eclipse project with sources for dependencies
EclipseKeys.withSource := true

// For sbt-dependency-graph
net.virtualvoid.sbt.graph.Plugin.graphSettings
resolvers += Classpaths.sbtPluginReleases

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")

addSbtPlugin("org.scoverage" %% "sbt-scoverage" % "0.99.5")

addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.4.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-start-script" % "0.10.0")

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4")
手动运行测试是正常的

$ scala -cp ~/.ivy2/cache/org.scalatest/scalatest_2.11/jars/scalatest_2.11-2.1.7.jar org.scalatest.run my.org.myproject.StackSpec
Run starting. Expected test count is: 2
StackSpec:
A Stack
- should pop values in last-in-first-out order
- should throw NoSuchElementException if an empty stack is popped
Run completed in 169 milliseconds.
Total number of tests run: 2
Suites: completed 1, aborted 0
Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
All tests passed.
这是完整的类路径

sbt > show fullClasspath
[info] List(Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/target/scala-2.11/classes), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/ant-1.7.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/ant-launcher-1.7.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/antlr-2.7.7.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/aopalliance-1.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/asm-4.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/asm-all-4.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/asm-analysis-4.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/asm-tree-4.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/asm-util-4.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/bsh-2.0b4.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/cglib-nodep-2.2.2.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/commons-codec-1.6.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/commons-collections-3.2.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/commons-exec-1.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/commons-io-2.2.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/commons-io-2.4.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/commons-lang3-3.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/commons-logging-1.1.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/cssparser-0.9.9.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/easymock-3.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/easymockclassextension-3.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/guava-14.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/guice-2.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/hamcrest-core-1.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/hamcrest-library-1.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/htmlunit-2.12.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/htmlunit-core-js-2.12.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/httpclient-4.2.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/httpcore-4.2.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/httpmime-4.2.3.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/jcommander-1.27.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/jetty-http-8.1.9.v20130131.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/jetty-io-8.1.9.v20130131.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/jetty-util-8.1.9.v20130131.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/jetty-websocket-8.1.9.v20130131.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/jmock-2.5.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/jmock-legacy-2.5.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/jna-3.4.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/json-20080701.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/junit-4.10.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/mockito-all-1.9.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/nekohtml-1.9.18.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/netty-3.5.2.Final.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/objenesis-1.2.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/parboiled-core-1.1.6.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/parboiled-java-1.1.6.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/pegdown-1.4.2.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/platform-3.4.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/sac-1.3.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scala-compiler-2.11.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scala-library-2.11.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scala-parser-combinators_2.11-1.0.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scala-reflect-2.11.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scala-xml_2.11-1.0.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scalac-scoverage-plugin_2.11-0.99.5-javadoc.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scalac-scoverage-plugin_2.11-0.99.5-sources.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scalac-scoverage-plugin_2.11-0.99.5.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scalacheck_2.11-1.11.3.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scalacheck_2.11-1.11.4-javadoc.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scalacheck_2.11-1.11.4-sources.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scalacheck_2.11-1.11.4.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scalatest_2.11-2.1.7-javadoc.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scalatest_2.11-2.1.7-sources.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/scalatest_2.11-2.1.7.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/selenium-android-driver-2.35.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/selenium-api-2.35.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/selenium-chrome-driver-2.35.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/selenium-firefox-driver-2.35.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/selenium-htmlunit-driver-2.35.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/selenium-ie-driver-2.35.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/selenium-iphone-driver-2.35.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/selenium-java-2.35.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/selenium-remote-driver-2.35.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/selenium-safari-driver-2.35.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/selenium-support-2.35.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/serializer-2.7.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/snakeyaml-1.12.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/stringtemplate-3.2.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/test-interface-1.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/testng-6.8.7.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/webbit-0.4.14.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/xalan-2.7.1.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/xercesImpl-2.10.0.jar), Attributed(/Users/hanxue/Code/Scala/entrypass-controller-simulator/lib/xml-apis-1.4.01.jar), Attributed(/Users/hanxue/.ivy2/cache/com.typesafe.akka/akka-actor_2.11/jars/akka-actor_2.11-2.3.3.jar), Attributed(/Users/hanxue/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.1.jar), Attributed(/Users/hanxue/.ivy2/cache/com.typesafe/config/bundles/config-1.2.1.jar), Attributed(/Users/hanxue/.ivy2/cache/org.scala-lang/scala-swing/jars/scala-swing-2.11.0-M7.jar), Attributed(/Users/hanxue/.ivy2/cache/commons-io/commons-io/jars/commons-io-2.4.jar))
[success] Total time: 0 s, completed Jun 17, 2014 11:52:15 AM
这是测试依赖关系树

> test:dependency-tree
[info] net.entrypass:controller-simulator_2.11:0.1 [S]
[info]   +-com.typesafe.akka:akka-actor_2.11:2.3.3
[info]   | +-com.typesafe:config:1.2.1
[info]   | +-org.scala-lang:scala-library:2.11.1
[info]   | 
[info]   +-commons-io:commons-io:2.4
[info]   +-org.scala-lang:scala-library:2.11.1
[info]   +-org.scala-lang:scala-swing:2.11.0-M7
[info]   | +-org.scala-lang:scala-library:2.11.0-M7 (evicted by: 2.11.1)
[info]   | +-org.scala-lang:scala-library:2.11.1
[info]   | 
[info]   +-org.scalacheck:scalacheck_2.11:1.11.4 [S]
[info]   | +-org.scala-lang.modules:scala-parser-combinators_2.11:1.0.1 [S]
[info]   | | +-org.scala-lang:scala-library:2.11.1
[info]   | | 
[info]   | +-org.scala-lang:scala-library:2.11.1
[info]   | +-org.scala-sbt:test-interface:1.0
[info]   | 
[info]   +-org.scalatest:scalatest_2.11:2.1.7 [S]
[info]     +-org.scala-lang.modules:scala-parser-combinators_2.11:1.0.1 [S]
[info]     | +-org.scala-lang:scala-library:2.11.1
[info]     | 
[info]     +-org.scala-lang.modules:scala-xml_2.11:1.0.1 [S]
[info]     | +-org.scala-lang:scala-library:2.11.1
[info]     | 
[info]     +-org.scala-lang:scala-library:2.11.1
[info]     +-org.scala-lang:scala-reflect:2.11.0 [S]
[info]       +-org.scala-lang:scala-library:2.11.1
我查看了
~/.ivy2/cache
以查看是否存在任何冲突库,并找到了ScalaTest 2.1.6。删除版本后,仍然会出现相同的错误

如何删除
java.lang.NoClassDefFoundError:sbt/testing/Framework
错误

注意:请忽略目录结构。为简洁而作的修改

更新1
  • Scala版本(在
    build.sbt
    中):2.11.0
  • sbt版本:0.13.2
项目/构建.属性

sbt.version=0.13.2
项目/插件.sbt

import com.typesafe.sbt.SbtStartScript

name := "myproject"

organization := "my.org"

version := "0.1"

scalaVersion := "2.11.0"

//Define dependencies. These ones are only required for Test and Integration Test scopes.
libraryDependencies ++= Seq(
    "org.scalatest"   %% "scalatest"    % "2.1.7"   % "test,it",
    "org.scalacheck"  %% "scalacheck"   % "1.11.4"      % "test,it",
    "com.typesafe.akka" %% "akka-actor" % "2.3.3",
    "org.scala-lang" % "scala-swing" % "2.11.0-M7",
    "commons-io" % "commons-io" % "2.4"
)

// For Settings/Task reference, see http://www.scala-sbt.org/release/sxr/sbt/Keys.scala.html

// Compiler settings. Use scalac -X for other options and their description.
// See Here for more info http://www.scala-lang.org/files/archive/nightly/docs/manual/html/scalac.html 
scalacOptions ++= List("-feature","-deprecation", "-unchecked", "-Xlint")

// ScalaTest settings.
// Ignore tests tagged as @Slow (they should be picked only by integration test)
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-l", "org.scalatest.tags.Slow", "-u","target/junit-xml-reports", "-oD", "-eS")

//Style Check section 
org.scalastyle.sbt.ScalastylePlugin.Settings

org.scalastyle.sbt.PluginKeys.config <<= baseDirectory { _ / "src/main/config" / "scalastyle-config.xml" }

// Generate Eclipse project with sources for dependencies
EclipseKeys.withSource := true

// For sbt-dependency-graph
net.virtualvoid.sbt.graph.Plugin.graphSettings
resolvers += Classpaths.sbtPluginReleases

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")

addSbtPlugin("org.scoverage" %% "sbt-scoverage" % "0.99.5")

addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.4.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-start-script" % "0.10.0")

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4")
project/Build.scala

import sbt._
import Keys._

/**
 * Additional configuration
 */ 
object Build extends Build {

  lazy val integrationTest =
    Project("root", file("."))
      .configs( IntegrationTest )
        .settings( Defaults.itSettings : _* )
        .settings(
          scalaSource in IntegrationTest <<= baseDirectory / "src/test/scala",
          resourceDirectory in IntegrationTest <<= baseDirectory / "src/test/resources",
          parallelExecution in IntegrationTest := false,
          testOptions in IntegrationTest += Tests.Argument(TestFrameworks.ScalaTest, "-n", "org.scalatest.tags.Slow"))

}
导入sbt_
导入密钥_
/**
*附加配置
*/ 
对象构建扩展了构建{
延迟val集成测试=
项目(“根”,文件(“.”)
.configs(集成测试)
.settings(默认值。设置:*)
.设置(

IntegrationTest中的scalaSource我无法重现错误-它只在我的机器上使用您的设置。是否可以从github克隆项目?这样我们可以消除彼此环境之间的任何差异。sbt/testing/Framework来自sbt的测试接口jar,闻起来像是sbt版本问题,sbt的哪个版本您使用的是启动器吗?我无法使用以下生成文件的示例项目重现此问题: