how do I perform follow up tasks after failure
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I developed a unittest framework using matlab.unittest.testCase class. I want to perform some actions after a certain test passes or fails.
testCase.VerifyEqual(actualValue, ecxpectedValue);
%if failed perform may be the following
testCase.failureCount = testCase.failureCount +1 ;
How do I do this? I tried usinng onFailure method by adding some function, but that is not working as expected.
the following didn't work as expected
testcase.onFailure(@() functionCallOnFailure())
Can anyone answer this?
thanks in advance.
0 commentaires
Réponse acceptée
akshatsood
le 5 Fév 2024
Modifié(e) : akshatsood
le 5 Fév 2024
I understand that you seek guidance on performing follw up tasks after a certain function pases or fails. When writing tests, it is often useful to provide additional information that can help diagnose the reason for a test failure. You should look upto the "diagnostic" argument available while calling "verifyEqual".
verifyEqual(testCase,actual,expected,diagnostic)
where "diagnostic" can be a string, character vector, function handle, or "matlab.unittest.diagnostics.Diagnostic" object that provides additional information when a test fails. The "diagnostic" argument allows you to specify a custom message or a diagnostic procedure to run when "verifyEqual" determines that "actual" does not match "expected". This can greatly aid in understanding the context and cause of test failures.
For your use case, you have the option to provide function handles that facilitate any subsequent actions you require. Should you encounter any challenges, please do not hesitate to reach out for assistance.
I hop this helps
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Configure and View Diagnostics dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!