Main Content

slreq.verification.services.TAP class

Package: slreq.verification.services
Superclasses:

Work with external results sources

Since R2020a

Description

Instances of the slreq.verification.services.TAP provides utilities for interpreting TAP (Test Anything Protocol) result files for verification.

Creation

Service objects used in the custom logic of GetResultFcn to script up result fetching logic.

tapService = slreq.verification.services.TAP() directs the result fetching logic to the TAP file.

Output Arguments

expand all

Service used in GetResultFcn to script up result fetching logic

Methods

The output is result that is an instance of the tapService object. For the resultFile with testID, the GetResultFcn function returns the result for that testID:

result = tapService.getResult(testID, resultFile);

The GetResultFcn fetches the result for the testID with test points in the resultFile using:

result = tapService.getAllResults(resultFile);

Examples

collapse all

In this example, you link a requirement to a MATLAB® script. The verification status in the Requirements Editor reflects the test results. This example performs the steps described in Linking to a Test Script. To run this example, click Open Example and run it. This example uses:

  • A requirements set file named counter_req.slreqx.

  • A MATLAB script called runmytests.m that runs a test for the Counter class in Counter.m. The test script contains custom methods that write results a TAP format to a file named results.tap.

Register the Link Type

Before creating the links, you need to register the link type from the requirements set file. Open the requirements file counter_req.slreqx in the Requirements Editor:

reqSet = slreq.open('counter_req.slreqx');

requirement_set_tap.png

Register the link type that is specific to the external test file. The domain registration needed for this example is linktype_mymscripttap.m. To register the custom link type linktype_mymscripttap.m, type:

rmi register linktype_mymscripttap;

The custom logic in the GetResultFcn function locates the test file that corresponds to the test case and fetches the results from that test file. For more information about GetResultFcn, see Links and Link Types.

Note: If the register command returns any warning, then you must unregister the file and run the command again. To unregister the file, enter rmi unregister linktype_mymscripttap.

Create the Link

Make the struct containing properties of the external test. To create the link, at the command prompt, enter:

externalSource.id = 'counterStartsAtZero';
externalSource.artifact = 'runmytests.m';
externalSource.domain = 'linktype_mymscripttap';

The requirement related to the link has its SID set to 2. To find the requirement related to the link, enter:

requirement = reqSet.find('Type', 'Requirement', 'SID', 2);

To create the link, enter:

link = slreq.createLink(requirement, externalSource);

This command creates the link between the test case counterStartsAtZero and the requirement with the SID of 2. In the Requirements Editor, the link appears in the Details pane, under Links.

Note: In order to avoid stale results, make sure that the timestamp of result file is latest than the timestamp of link creation. Open the result file, make a dummy change in the file and save it again to get the latest timestamp. For more information, see Requirement Links and Link Types.

View the Verification Status

To view the verification status, you need to first update the verification status for the requirement set. At the MATLAB command prompt, type:

reqSet.updateVerificationStatus;

To see the verification status column in the Requirements Editor, ensure that showColumns_16.pngColumns > Verification Status is selected. After the update, fetch the verification status for the requirement:

status = reqSet.getVerificationStatus;

The Requirements Editor shows the verification status for entire requirements set that are passed or failed.

verification_status_counter_starts_at_zero.png

The verification status for the requirements for the counterStartsAtZero is fully verified. Open the Requirements Editor to see the verification status:

reqSet = slreq.open('counter_req.slreqx');

The verification status shows that out of three tests, one test passed. Click Refresh to see the verification status for the requirements in the Requirements Editor.

overall_verification_status_counter_starts_at_zero.png

Unregister the link type.

rmi unregister linktype_mymscripttap;

Version History

Introduced in R2020a