【问题标题】:java sbt test: exception ignored if test is run with SpringJUnit4ClassRunnerjava sbt test:如果使用 SpringJUnit4ClassRunner 运行测试,则会忽略异常
【发布时间】:2015-05-23 13:26:40
【问题描述】:

当测试抛出的异常被 sbt 忽略并且不会破坏构建时遇到问题。

一些代码:

测试:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MyConfig.class)
public class MyTest {

    @Autowired
    private ClassBeingTested sut;

    @Test
    public void test() {
        if (true)
            throw new Exception(); //it must break the build, but it doesn't
    }
}

如果我删除 SpringJUnit4ClassRunner 并自己注入依赖项,它将按预期破坏构建。

如果我禁止 sbt 分叉测试过程,它也会破坏构建:

lazy val myProject = project.in(file("foo/proj"))
    .settings(....)
    .settings(sbt.Keys.fork in Test := false) <- the exception breaks the build

知道为什么会这样吗?

提前感谢

【问题讨论】:

    标签: java junit sbt spring-test


    【解决方案1】:

    看起来这是 SBT 的问题。一旦我将它从 0.13.5 更新到 0.13.8,问题就消失了。

    【讨论】:

      猜你喜欢
      • 2016-09-14
      • 2019-11-04
      • 2015-04-27
      • 2014-03-01
      • 2014-07-26
      • 1970-01-01
      • 2020-02-27
      • 1970-01-01
      • 2017-08-27
      相关资源
      最近更新 更多