[英]java sbt test: exception ignored if test is run with SpringJUnit4ClassRunner
Got an issue when exception thrown by test is ignored by sbt and does not break the build. 当测试抛出的异常被sbt忽略并且不会破坏构建时,出现了一个问题。
Some code: 一些代码:
Test: 测试:
@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
}
}
If i remove SpringJUnit4ClassRunner and inject dependency myself it will break the build as expected. 如果我删除SpringJUnit4ClassRunner并自己注入依赖项,它将按预期破坏构建。
If i forbid sbt to fork test process it will also break the build: 如果我禁止sbt分叉测试过程,它也会破坏构建:
lazy val myProject = project.in(file("foo/proj"))
.settings(....)
.settings(sbt.Keys.fork in Test := false) <- the exception breaks the build
Any idea why it happens? 知道为什么会发生吗?
Thanx in advance 提前感谢
Looks like it was an issue of SBT. 看起来这是SBT的问题。 once i updated it from 0.13.5 to 0.13.8 the problem was gone. 一旦我将其从0.13.5更新到0.13.8,问题就消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.