我使用Specs BDD库编写Scala单元测试(http://code.google.com/p/specs).在我的代码中,如果我想断言抛出类型为ClassNotFoundException的异常,那么我可以编写以下内容码:
a must throwA[ClassNotFoundException]
Run Code Online (Sandbox Code Playgroud)
但是,我想测试相反的情况,iei想断言"不会"抛出ClassNotFoundException类型的异常.
我尝试使用非否定匹配器,如下:
a must throwA[ClassNotFoundException].not
Run Code Online (Sandbox Code Playgroud)
但那没有用.我收到编译错误.那么,有什么方法可以断言例如ClassNotFoundException类型的异常不被抛出?
请帮助谢谢