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!