我正在尝试拦截测试中的异常(带有异常消息)。
我的测试代码:
class Test4 extends WordSpec with Matchers with ScalaFutures with ScalatestRouteTest {
"should fail if no valid" should {
"should throw ex if name is not valid" in {
whenReady(userService.createUser(wrongNameRequest)) {
_ shouldBe UserCreateException("incorrect name")
}
}
}
但是看起来scalatest没有对我的“应该”做出正确的React。它表现得好像没有拦截存在一样。(我可以肯定:_ shouldBe用户创建异常(“不正确的名称”))
所以在测试结果中,我得到了这个:
- should should throw ex if a name is not valid***FAILED***
[info] The future returned an exception of type: userapi.model.UserCreateException, with the message: incorrect name.
1条答案
按热度按时间cnwbcb6i1#
解决了,我应该用全名-