How to unit test with verifyWarning?
1 次查看(过去 30 天)
显示 更早的评论
Hello, I am unit testing the following function:
function [adjdate] = AdjStartDate(startDate) if ~strcmp(startDate,datestr(datetime('01-Feb-2000','InputFormat','dd-MMM-yyyy'),'yyyy-mm-dd')) adjdate=datestr(datetime('01-Feb-2000','InputFormat','dd-MMM-yyyy'),'yyyy-mm-dd'); warning('Start date has been modified.') else adjdate=startDate; end
Specifically, I want to unit test if the function gives the warning 'Start date has been modified." if the date is changed. I tried the following code:
% test if warning is shown, if input date changes function testWarning(testCase) actSolution=AdjStartDate('2000-01-01'); verifiableWaning(testCase,actSolution) end
Unfortunately, my unit tests show an error. There is something written about the warning ID, but I did not specified any warning ID in the function AdjStartDate.m Would you give me some assistance?
3 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Hypothesis Tests 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!