필터 지우기
필터 지우기

how do I perform follow up tasks after failure

조회 수: 1 (최근 30일)
Harish
Harish 2024년 2월 5일
편집: akshatsood 2024년 2월 5일
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.

채택된 답변

akshatsood
akshatsood 2024년 2월 5일
편집: akshatsood 2024년 2월 5일
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개)

카테고리

Help CenterFile Exchange에서 Extend Testing Frameworks에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by