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.

Functions

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
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

Inputs

sltest.testmanager.TestInputAdd or modify test input
sltest.import.sldvDataCreate test cases from Simulink Design Verifier results
sltest.io.SimulinkTestSpreadsheetRead spreadsheet in format used by Simulink Test
sltest.testmanager.registerTestAdapterRegister adapter to convert test data

Outputs

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
sltest.testmanager.OutputTriggerResultSignal logging output trigger results
sltest.testmanager.TriggerModeOutput trigger type

Iterations

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
loadSystem Load model for MATLAB-based Simulink test
simulate Simulate model or Simulink.SimulationInput for MATLAB-based Simulink test
sltest.TestCase.forInteractiveUseCreate test case for interactive use
createTemporaryFolder Create temporary folder
assumeSignalsMatchAssume two data sets are equivalent
assertSignalsMatchAssert two data sets are equivalent
fatalAssertSignalsMatchFatally assert two data sets are equivalent
verifySignalsMatchVerify two sets of data are equivalent
sltest.harness.SimulationInputCreate test harness simulation input for MATLAB-based Simulink tests
createSimulationInput Create simulation input object
addModelCoverageEnable model coverage collection for Simulink tests
addSimulinkTestResultsEnable pushing test results to Simulink Test Manager
sltest.plugins.MATLABTestCaseIntegrationPluginAdd simulation and test results for MATLAB-based Simulink tests to Test Manager
sltest.plugins.ToTestManagerLogOutput stream to write text to Test Manager result Logs for MATLAB-based Simulink tests
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
sltest.harness.getHarnessCreateDefaultsGet harness creation default values
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

Scenarios

sltest.testsequence.activateScenarioSet Test Sequence block scenario as active
sltest.testsequence.addScenarioAdd new scenario to Test Sequence block
sltest.testsequence.deleteScenarioDelete scenario from Test Sequence block
sltest.testsequence.editScenarioEdit Test Sequence block test scenario properties
sltest.testsequence.getActiveScenarioGet Test Sequence block active scenario
sltest.testsequence.getAllScenariosGet names of all Test Sequence block scenarios
sltest.testsequence.getScenarioControlSourceGet source that controls Test Sequence active scenario
sltest.testsequence.isUsingScenariosDetermine whether Test Sequence block uses scenarios
sltest.testsequence.setScenarioControlSourceSet source controlling Test Sequence active scenario
sltest.testsequence.useScenarioConvert Test Sequence block to scenario mode
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
sltest.testmanager.AssessmentSymbolSymbol used in assessment
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
sltest.testmanager.mergeCoverageMerge coverage results from two or more test result sets
sltest.testmanager.TestOptionsOptions for adding test coverage
sltest.xil.framework.FrameworkInitialize test bench, start and stop simulation, and display test bench, variable, and task
sltest.xil.framework.FrameworkConfigurationConfigure test bench ports and variable mapping
sltest.xil.framework.TestVariableRead and write variable mapped to test bench
sltest.xil.framework.StimulationControl external input to test bench
sltest.xil.framework.AcquisitionControl signal data logging on test bench and retrieve logged data
sltest.CodeImporterImport C or C++ code into Simulink for testing
sltest.CodeImporter.SandboxSettingsSandbox settings for C code testing
sltest.testmanager.ResultSetAccess results 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.reportGenerate report of test results
sltest.testmanager.TestResultReportCustomize generated results report
sltest.testmanager.TestSpecReportGenerate report of test specifications
sltest.testmanager.DiagnosticRecordView custom criteria diagnostic information
sltest.testmanager.TestResultContainerContainer for MLDATX test file results from MATLAB Unit Test run or runInParallel
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.closeClose the Simulink Test Manager

Topics