How to unit test with verifyWarning?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Hypothesis Tests in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!