【发布时间】:2016-07-13 07:47:45
【问题描述】:
我正在使用 Matlab 的 unittest 来测试对无效参数的处理。
在测试中我有一条线
t.verifyError(@myObject.myMethod, 'MATLAB:nonStrucReference');
在 Matlab R2014a 中工作正常,但在 Matlab R2016a 中失败并显示消息
---------------------
Framework Diagnostic:
---------------------
verifyError failed.
--> The function threw the wrong exception.
Actual Exception:
'MATLAB:structRefFromNonStruct'
Expected Exception:
'MATLAB:nonStrucReference'
我想知道是否可以测试是否抛出了异常之一。
我知道可以写
t.verifyError(@myObject.myMethod, ?MException);
但更具体的会更好。
【问题讨论】:
标签: matlab unit-testing exception-handling