Main Content

Test Scripts

Create and run tests using command-line functions and scripts, set test preferences

You can use the Simulink® Test™ programmatic interface to:

  • Create test scripts and functions.

  • Run tests from the command line.

  • Set up and standardize your testing environment.

You can use scripts and functions to repeat the same test strategy on multiple systems, or perform regression testing. These functions and classes cover test authoring, execution, and results in Simulink Test. If you want to combine existing Simulink tests with MATLAB® tests, or run tests with continuous integration, use the MATLAB Unit Test Framework. See Continuous Integration. If you want to run tests on third-party test benches, see ASAM XIL Tests.

Simulink Test also provides graphical user interfaces to help you create and run tests. For more information, see Test Authoring, Test Execution, and Results, Reporting, and Test File Management.


expand all

Test Files

sltest.testmanager.TestFileCreate or modify test file
sltest.testmanager.TestSuiteCreate or modify test suite
sltest.testmanager.TestCaseCreate or modify test case
sltest.testmanager.createTestForComponentCreate test cases and test harnesses for model or model components (Since R2020b)
sltest.testmanager.createTestsFromModelGenerate test cases from a model
sltest.testmanager.copyTestsCopy test cases or test suites to another location
sltest.testmanager.moveTestsMove test cases or test suites to a new location
sltest.testmanager.loadLoad a test file in the Simulink Test manager
sltest.testmanager.getTestFilesGet test files open in the Test Manager
sltest.testmanager.clearClear test files from the Test Manager
sltest.testmanager.RunPlatformsTest platform type (Since R2023b)


sltest.testmanager.TestInputAdd or modify test input
sltest.import.sldvDataCreate test cases from Simulink Design Verifier results spreadsheet in format used by Simulink Test (Since R2021a)
sltest.testmanager.registerTestAdapterRegister adapter to convert test data (Since R2022b)


sltest.testmanager.BaselineCriteriaAdd or modify baseline criteria
sltest.testmanager.EquivalenceCriteriaAdd or modify equivalence criteria
sltest.testmanager.SignalCriteriaAdd or modify signal criteria
sltest.testmanager.CustomCriteriaAdd or modify custom criteria
sltest.testmanager.LoggedSignalCreate or modify logged signals for use as simulation outputs
sltest.testmanager.LoggedSignalSetCreate or modify a set of logged signals
sltest.testmanager.OutputTriggerSignal logging output start and stop triggers (Since R2023a)
sltest.testmanager.OutputTriggerResultSignal logging output trigger results (Since R2023a)
sltest.testmanager.TriggerModeOutput trigger type (Since R2023a)

Fault Sets

sltest.testmanager.FaultSetCreate or modify fault set (Since R2024a)
sltest.testmanager.SpecifiedFaultCreate or modify faults added to fault sets in tests (Since R2024a)
sltest.testmanager.refreshFaultsRefresh list of faults available in specified model in Simulink Test Manager (Since R2024a)


sltestiterationCreate test iteration
sltest.testmanager.TestIterationCreate or modify test iteration
sltest.testmanager.ParameterSetAdd or modify parameter set
sltest.testmanager.ParameterOverrideAdd or modify parameter override

MATLAB-Based Simulink Tests

sltest.TestCaseTest case class for MATLAB-based Simulink tests (Since R2020b)
loadSystem Load model for MATLAB-based Simulink test (Since R2020b)
simulate Simulate model or Simulink.SimulationInput for MATLAB-based Simulink test (Since R2020b)
sltest.TestCase.forInteractiveUseCreate test case for interactive use (Since R2020b)
createTemporaryFolder Create temporary folder (Since R2020b)
assumeSignalsMatchAssume two data sets are equivalent (Since R2020b)
assertSignalsMatchAssert two data sets are equivalent (Since R2020b)
fatalAssertSignalsMatchFatally assert two data sets are equivalent (Since R2020b)
verifySignalsMatchVerify two sets of data are equivalent (Since R2020b)
sltest.harness.SimulationInputCreate test harness simulation input for MATLAB-based Simulink tests (Since R2020b)
createSimulationInput Create simulation input object (Since R2021a)
addModelCoverageEnable model coverage collection for Simulink tests (Since R2021a)
addSimulinkTestResultsEnable pushing test results to Simulink Test Manager (Since R2021a)
sltest.plugins.MATLABTestCaseIntegrationPluginAdd simulation and test results for MATLAB-based Simulink tests to Test Manager (Since R2020b)
sltest.plugins.ToTestManagerLogOutput stream to write text to Test Manager result Logs for MATLAB-based Simulink tests (Since R2020b)
sltest.plugins.ModelCoveragePluginCollect model coverage using the MATLAB Unit Test framework
sltest.harness.checkCompare component under test between harness model and main model
sltest.harness.cloneCopy test harness
sltest.harness.closeClose test harness
sltest.harness.convertConvert test harnesses between internal and external storage
sltest.harness.createCreate test harnesses
sltest.harness.setHarnessCreateDefaultsCustomize default property values for test harness creation (Since R2021b)
sltest.harness.getHarnessCreateDefaultsGet harness creation default values (Since R2021b)
sltest.harness.deleteDelete test harness
sltest.harness.exportExport test harness to Simulink model
sltest.harness.findFind test harnesses in model
sltest.harness.importImport Simulink model to test harness
sltest.harness.loadLoad test harness
sltest.harness.moveMove test harness from linked instance to library block or to a different harness owner
sltest.harness.openOpen test harness
sltest.harness.pushPush test harness workspace entries and configuration set to model
sltest.harness.rebuildRebuild test harness and update workspace entries and configuration parameter set based on main model
sltest.harness.setChange test harness property
sltest.harness.showDialogShow test harness dialog box

Steps, Transitions, and Symbols

sltest.testsequence.addStepAdd test sequence step
sltest.testsequence.addStepAfterAdd test sequence step after existing step
sltest.testsequence.addStepBeforeAdd test sequence step before existing step
sltest.testsequence.addSymbolAdd symbol to test sequence
sltest.testsequence.addTransitionAdd new transition to test sequence step
sltest.testsequence.deleteStepDelete test sequence step
sltest.testsequence.deleteSymbolDelete test sequence block symbol
sltest.testsequence.deleteTransitionDelete test sequence transition
sltest.testsequence.editStepEdit test sequence step
sltest.testsequence.editSymbolEdit symbol in Test Sequence block
sltest.testsequence.editTransitionEdit test sequence step transition
sltest.testsequence.findFind Test Sequence blocks
sltest.testsequence.findStepFind test sequence steps
sltest.testsequence.findSymbolFind Test Sequence block symbols
sltest.testsequence.getPropertyGet Test Sequence block properties
sltest.testsequence.newBlockCreate Test Sequence block
sltest.testsequence.readStepRead Test Sequence block steps
sltest.testsequence.readSymbolRead Test Sequence block symbol properties
sltest.testsequence.readTransitionRead properties of test sequence transition
sltest.testsequence.setPropertySet Test Sequence block properties


sltest.testsequence.activateScenarioSet Test Sequence block scenario as active (Since R2020b)
sltest.testsequence.addScenarioAdd new scenario to Test Sequence block (Since R2020b)
sltest.testsequence.deleteScenarioDelete scenario from Test Sequence block (Since R2020b)
sltest.testsequence.editScenarioEdit Test Sequence block test scenario properties (Since R2020b)
sltest.testsequence.getActiveScenarioGet Test Sequence block active scenario (Since R2020b)
sltest.testsequence.getAllScenariosGet names of all Test Sequence block scenarios (Since R2020b)
sltest.testsequence.getScenarioControlSourceGet source that controls Test Sequence active scenario (Since R2020b)
sltest.testsequence.isUsingScenariosDetermine whether Test Sequence block uses scenarios (Since R2020b)
sltest.testsequence.setScenarioControlSourceSet source controlling Test Sequence active scenario (Since R2020b)
sltest.testsequence.useScenarioConvert Test Sequence block to scenario mode (Since R2020b)
sltest.AssessmentAccess assessment from set
sltest.AssessmentSetAccess a set of assessments from a simulation
sltest.getAssessmentsReturns test assessment set object
sltest.testmanager.AssessmentLogical or temporal assessment object (Since R2022a)
sltest.testmanager.AssessmentSymbolSymbol used in assessment (Since R2022a)
sltest.testmanager.runRun tests with Test Manager
sltest.testmanager.CoverageSettingsModify coverage settings
sltest.plugins.coverage.CoverageMetricsSpecify coverage metrics for tests run with MATLAB Unit Test framework
sltest.testmanager.addTestsForMissingCoverageAdd tests to increase coverage (Since R2022a)
sltest.testmanager.mergeCoverageMerge coverage results from two or more test result sets
sltest.testmanager.TestOptionsOptions for adding test coverage (Since R2022a)
sltest.xil.framework.FrameworkInitialize test bench, start and stop simulation, and display test bench, variable, and task (Since R2022a)
sltest.xil.framework.FrameworkConfigurationConfigure test bench ports and variable mapping (Since R2022a)
sltest.xil.framework.TestVariableRead and write variable mapped to test bench (Since R2022a)
sltest.xil.framework.StimulationControl external input to test bench (Since R2022a)
sltest.xil.framework.AcquisitionControl signal data logging on test bench and retrieve logged data (Since R2022a)
sltest.CodeImporterImport C or C++ code into Simulink for testing (Since R2021a)
sltest.CodeImporter.SandboxSettingsSandbox settings for C code testing (Since R2021a)
sltest.testmanager.ResultSetAccess result set data
sltest.testmanager.TestFileResultAccess test file results data
sltest.testmanager.TestSuiteResultAccess test suite results data
sltest.testmanager.TestCaseResultAccess test case results data
sltest.testmanager.TestIterationResultAccess test iteration result data
sltest.testmanager.ComparisonRunResultAccess result of a comparison test
sltest.testmanager.ComparisonSignalResultAccess signal comparison results from a baseline or equivalence result
sltest.testmanager.CustomCriteriaResultView custom criteria test result
sltest.testmanager.importResultsImport Test Manager results file
sltest.testmanager.exportResultsExport results set from Test Manager
sltest.testmanager.getResultSetsReturns result set objects in Test Manager
sltest.testmanager.clearResultsClear results from Test Manager
sltest.testmanager.TimingInfoTest execution timing information object (Since R2024a)
sltest.testmanager.reportGenerate report of test results
sltest.testmanager.TestResultReportCustomize generated results report
sltest.testmanager.TestSpecReportGenerate report of test specifications (Since R2019b)
sltest.testmanager.DiagnosticRecordView custom criteria diagnostic information
sltest.testmanager.TestResultContainerContainer for MLDATX test file results from MATLAB Unit Test run or runInParallel (Since R2022b)
sltest.testmanager.AssessmentResultAccess logical and temporal assessment results data (Since R2023b)
sltest.testmanager.AssessmentResultSetAccess logical and temporal assessment result set data (Since R2023b)
sltest.testmanager.viewLaunch the Simulink Test Manager
sltest.testmanager.setprefSet Test Manager preferences
sltest.testmanager.getprefGet Test Manager preferences
sltest.testmanager.OptionsReturn and specify test file options
sltest.testmanager.findFind test case in test file (Since R2024a)
sltest.testmanager.closeClose the Simulink Test Manager