【发布时间】: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