Main Content

addFaultSet

Add fault set to test case

Since R2024a

Syntax

fs = addFaultSet(tc)
fs = addFaultSet(tc,Name=Value)

Description

fs = addFaultSet(tc) adds a new fault set to the specified test case. You must have Simulink® Test™ to use this method.

fs = addFaultSet(tc,Name=Value) adds a new fault set using one or more name-value arguments.

Input Arguments

expand all

Test case to add the fault set to, specified as a sltest.testmanager.TestCase (Simulink Test) object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: addFaultSet(tc,Name="myFaultSet") adds a fault set to the test case tc with the name "myFaultSet".

Fault set name, specified as a string scalar or character vector. If you do not specify this property, the fault set uses a predefined name, "Fault Set N", where N is the number of fault sets that use the default name.

Data Types: string | char

Equivalence test case simulation number that this fault set applies to, specified as the integer 1 or 2. You can use this argument only if you add the fault set to an equivalence test. See Test Two Simulations for Equivalence (Simulink Test).

Output Arguments

expand all

Fault set, returned as a sltest.testmanager.FaultSet object.

Examples

expand all

To add a fault set to the test file, load or create the test file, create the test suite and test case, and add the fault set.

tf = sltest.testmanager.TestFile("myTestFile.mldatx");
ts = sltest.testmanager.TestSuite(tf,"myTestSuite");
tc = sltest.testmanager.TestCase(ts,"simulation","myTestCase");
myFaultSet = addFaultSet(tc);

To add a fault set to the test file with the name myFaultSet, load or create the test file, create the test suite and test case, and add the fault set.

tf = sltest.testmanager.TestFile("myTestFile.mldatx");
ts = sltest.testmanager.TestSuite(tf,"myTestSuite");
tc = sltest.testmanager.TestCase(ts,"simulation","myTestCase");
myFaultSet = addFaultSet(tc,Name="myFaultSet");

Version History

Introduced in R2024a