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

1 次查看(过去 30 天)
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

采纳的回答

Animesh
Animesh 2023-3-8
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Outputs 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by