Main Content

Test Tasks and Queries

With the CI/CD Automation for Simulink Check support package, you can define a development and verification process by adding tasks to a process model and using queries to find relevant artifacts like models, requirements, and test cases. If you are trying to debug or test a task or query, it can be helpful to run the task or query directly from the MATLAB® Command Window. To test a task, you can find the ID for a specific task iteration and use the runprocess function to run that task iteration. To test a query, you can create an instance of the query and use the run method to get the artifacts that the query returned.

This example shows how to test a built-in query and then use the artifacts that the query returns to test a built-in task. For more information on built-in tasks and queries, see the Built-In Tasks and Built-In Queries. To evaluate the task inputs and outputs defined by your process model, you can dry run tasks as shown in Dry Run Tasks to Test Process Model.

Open Project

Open a project. For this example, you can open the Process Advisor example project.

processAdvisorExampleStart

Find Artifacts Using Query

Suppose that you want to test the built-in query padv.builtin.query.FindModels.

  1. In the MATLAB Command Window, create an instance of the query.

    q = padv.builtin.query.FindModels;

  2. To see which artifacts the query returns, run the query by using the run method.

    artifacts = run(q)
    artifacts = 
    
      1×5 Artifact array with properties:
    
        Type
        Parent
        ArtifactAddress
        Alias
    In this example, the query returns the five models in the example project. If you open the Alias property, you can see the names of each of the models returned by the padv.builtin.query.FindModels query.
    artifacts.Alias

  3. To filter the artifacts returned by the query, you can modify the behavior of the query using the name-value arguments. For example, to exclude artifacts that contain Control in the file path, you would specify:

    q = padv.builtin.query.FindModels(ExcludePath = "Control");

  4. Re-run the query to see the updated query results.

    artifacts = run(q)
    artifacts = 
    
      Artifact with properties:
    
                   Type: "sl_model_file"
                 Parent: [0×0 padv.Artifact]
        ArtifactAddress: [1×1 padv.util.ArtifactAddress]
                  Alias: "AHRS_Voter.slx"
    For this example, the query returns a single Simulink® model, AHRS_Voter.slx, since AHRS_Voter.slx is the only model that does not contain Control in its file path.
    artifacts.ArtifactAddress
    ans = 
    
    ArtifactAddress
    
          FileAddress: "02_Models/AHRS_Voter/specification/AHRS_Voter.slx"
        OwningProject: "ProcessAdvisorExample"
    IsSubFileArtifact: 0
    
    If the artifact is in a referenced project, the OwningProject returns the name of the referenced project. If you need to know which project contains an artifact, you can use the getOwningProject function on the artifact address object. For more information, see padv.util.ArtifactAddress.

Run Task for Specific Artifacts

Suppose that you want to run the task padv.builtin.task.GenerateSimulinkWebView on the AHRS_Voter model returned by a query.

You can run a specific task iteration by specifying the Tasks and FilterArtifact name-value arguments for the runprocess function.

runprocess(...
Tasks = "padv.builtin.task.GenerateSimulinkWebView",...
FilterArtifact = artifacts(1))

You can use the other name-value arguments of runprocess to specify how the task iteration runs. For example, Force = true forces the task iteration to run, even if the results are already up-to-date and Isolation = true has the task iteration run without running any of its dependencies.

runprocess(...
Tasks = "padv.builtin.task.GenerateSimulinkWebView",...
FilterArtifact = artifacts(1),...
Force = true,...
Isolation = true)
For more information, see runprocess.

See Also

| |

Related Topics