简体   繁体   English

sbt集成测试在测试失败时返回退出代码0

[英]sbt integration tests returning exit code 0 when tests fail

I am using sbt 0.13.9 (and previously 0.13.8) and Scala 2.11.6. 我使用的是sbt 0.13.9(以前是0.13.8)和Scala 2.11.6。

When running integration tests for my project, sbt always returns "success" with exit code 0 even when it acknowledges test failures. 当为我的项目运行集成测试时,即使它确认测试失败,sbt总是返回“成功”,退出代码为0。 The integration test configuration and settings are the stock ones from sbt (see build.sbt below). 集成测试配置和设置是来自sbt的库存(参见下面的build.sbt)。

Notice how the failure does not print out a "Failed tests:" section unlike the unit test failure. 请注意,与单元测试失败不同,失败不会打印出“失败的测试:”部分。

集成测试的图片失败,sbt成功

This is odd compared to the unit tests, which do correctly trigger sbt to return an exit code of 1. 与单元测试相比,这是奇怪的,单元测试正确地触发sbt以返回退出代码1。

单元测试失败的图片也失败了

With both my unit and integration tests, I had to enable forking to avoid some classloader issues due to dynamically loading a Java library. 通过我的单元和集成测试,我必须启用分叉以避免由于动态加载Java库而导致的一些类加载器问题。 If forking was the problem, I would assume that I would see the issue with unit tests as well. 如果分叉是问题,我会假设我也会看到单元测试的问题。

My integration tests do involve starting external processes, which I don't know if that affects the results from sbt or not. 我的集成测试确实涉及启动外部进程,我不知道这是否会影响sbt的结果。

The project in question can be found here: https://github.com/chipsenkbeil/scala-debugger 有问题的项目可以在这里找到: https//github.com/chipsenkbeil/scala-debugger

The project's build.sbt is as follows: 该项目的build.sbt如下:

//
// DEBUGGER API PROJECT CONFIGURATION
//
lazy val scalaDebuggerApi = project
  .in(file("scala-debugger-api"))
  .configs(IntegrationTest)
  .settings(Common.settings: _*)
  .settings(Defaults.itSettings: _*)
  .settings(Seq(
    name := "scala-debugger-api",

    // NOTE: Fork needed to avoid mixing in sbt classloader, which is causing
    //       LinkageError to be thrown for JDI-based classes
    fork in Test := true,
    fork in IntegrationTest := true,

    libraryDependencies ++= Seq(
      "org.slf4j" % "slf4j-api" % "1.7.5",
      "org.slf4j" % "slf4j-log4j12" % "1.7.5" % "test,it",
      "log4j" % "log4j" % "1.2.17" % "test,it",
      "org.scalatest" %% "scalatest" % "2.2.1" % "test,it",
      "org.scalamock" %% "scalamock-scalatest-support" % "3.2.1" % "test,it"
    ),
    // JDK Dependency (just for sbt, must exist on classpath for execution,
    // cannot be redistributed)
    internalDependencyClasspath in Compile +=
      { Attributed.blank(Build.JavaTools) },
    internalDependencyClasspath in Runtime +=
      { Attributed.blank(Build.JavaTools) },
    internalDependencyClasspath in Test +=
      { Attributed.blank(Build.JavaTools) },
    internalDependencyClasspath in IntegrationTest +=
      { Attributed.blank(Build.JavaTools) }
  ): _*)
  .dependsOn(scalaDebuggerTest % "test->compile;it->compile")

//
// DEBUGGER TEST CODE PROJECT CONFIGURATION
//
lazy val scalaDebuggerTest = project
  .in(file("scala-debugger-test"))
  .settings(Common.settings: _*)
  .settings(
    // Do not publish the test project
    publishArtifact := false,
    publishLocal := {}
  )

//
// MAIN PROJECT CONFIGURATION
//
lazy val root = project
  .in(file("."))
  .settings(Common.settings: _*)
  .settings(
    name := "scala-debugger",
    // Do not publish the aggregation project
    publishArtifact := false,
    publishLocal := {}
  ).aggregate(scalaDebuggerApi, scalaDebuggerTest)

Looks like you hit an open issue: https://github.com/sbt/sbt/issues/1890 . 看起来你遇到了一个悬而未决的问题: https//github.com/sbt/sbt/issues/1890 It's related to: https://github.com/scalatest/scalatest/issues/432 . 它与以下内容有关: https//github.com/scalatest/scalatest/issues/432 Try to get the latest version and see if it's at least partially fixed, ie when not running in parallel. 尝试获取最新版本并查看它是否至少部分修复,即不并行运行时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM