0

I have a class (call it filetest) in a class library (b), which is trying to get files from a directory which does not exist. This throws an exception fine, and there is a throw in the catch block.

Above in the callstack in a class called Test (excuse the names as this si a test), there I call the class filetest and the method which reads the wrong directory, and try to catch the exception.

I have an NUnit test which calls the class/method responsible for invking filetest and the method which reads the wrong directory. I have an expectedexception attribute, set to DirectoryNotFoundException, but the test fails saying "UnsupportException thrown". Am I wrong to expect an exception in the method in Test?

Thanks

4

1 回答 1

0

. 期望测试中的方法出现异常我错了吗?

是的,原因如下:

  • 假设是错误的
  • 单个测试可能有多个例外
于 2013-12-06T01:29:51.570 回答