Is there a way to use fatalAssert statements in CustomCriteria or Clean-Up Callbaks ?

2 visualizzazioni (ultimi 30 giorni)
Hi
I'm trying to somehow customize the execution of a testfile, meaning if a certain test case fails, then it shoul not go any further, for example if I get an error while setting up a power supply then there is no reason in continuing.
I was attempting to use the fatalAssertFail statement or something similar for this in the Custom Criteria section, but I get an error statment that fatalAssertions and Assumptions are not allowed.
I tried experimenting with the code below in the Custom Criteria section of the Simulink Test Manager :
% no postprocessing
import matlab.unittest.TestCase;
import matlab.unittest.constraints.*
import matlab.unittest.qualifications.QualificationEventData
import matlab.unittest.qualifications.FatalAssertable
PSU = true;
test.fatalAssertReturnsTrue(PSU,'PSU passed')
The error code is :
-------------------------------------------------------------------- Fatal Assertion and Assumption qualifiers are not supported. Use Verification and Assertion. --------- Error ID: --------- MATLAB:unittest:FatalAssertable:FatalAssertionFailed -------------- Error Details: -------------- Fatal assertion failed.
How is the fatal Assert intended to be used ? Or what are the limitations ?
Thanks in advance

Risposta accettata

Animesh
Animesh il 8 Mar 2023
Hello,
No, “fatalAssert” statements cannot be used in Custom Criteria or Clean-Up Call-backs in MATLAB. “fatalAssert” statements are intended to immediately terminate the test case execution upon failure and report the failure as a fatal error. This is not suitable for use in Custom Criteria or Clean-Up Call-backs, as they are not expected to terminate the test case execution.
Instead, you can use “assert” or “verify” statements with appropriate qualifiers in your Custom Criteria or Clean-Up Call-backs.
You can read more about “assert” here - https://www.mathworks.com/help/sltest/ref/assert.html
You can read more about “verify” here – https://www.mathworks.com/help/sltest/ref/verify.html

Più risposte (0)

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by