Generate tests
Choose paths in the model to test based on your business objectives.
Select a testing coverage strategy
A model can have a huge number of possible business processes. In the Paths tab you can select a strategy that automatically converts your business processes to paths. You can then generate tests for the paths. This helps you plan your testing according to your business objectives.
To plan your model testing using strategies:
-
In a model, select the Paths tab.
-
Click Coverage strategy. The Strategy and Constraints dialog box opens.
-
Click the Coverage strategy drop down arrow, and select a strategy:
Coverage strategy Description Full Coverage – Simple Displays the path combinations of all possible flows in the model. You can filter the paths by defining constraints in the same dialog box. Sanity Test Selects paths that cover all units in the model at least once. This ensures that each unit is tested at least once. Every Junction Combination Covers all possible entry and exit combinations of each decision point.
The Optimized checkbox generates the smallest number of paths to include all entry and exit options. If you do not select this option, MBT creates a distinct path for each of the decision point options, ensuring greater coverage.
Full Coverage - Agile Based You can combine MBT with your Agile work processes. For details, see Agile-based testing.
Full Coverage – Unit Recent Failure This strategy provides recommendations of paths that include units identified as potentially risky.
MBT assigns a weight of 1 to each unit that experienced a failure in its last test run. You can then test paths with the highest weights, to cover the units that have the greatest degree of risk.
-
Filter the paths further by using the fields in the Constraints section.
-
Close the dialog box. The list of paths is filtered to reflect your strategy.
Draw a path manually (optional)
You can manually draw your testing path to include specific units that you know are important to test based on your application needs.
To draw a path:
-
In a model, select the Paths tab.
-
Click Draw a path.
-
In the Path Preview pane on the right side of the screen, click the units that you want to include in your testing path.
-
Click Generate Test, and proceed as described below.
Note: If the path you drew already exists, a message is displayed. The generated test is added in the Tests tab, but the path is not added in the Paths tab.
Create tests
Create tests from the selected paths. You can generate tests only for paths that don't yet have test coverage.
The tests are created as MBT tests.
To create tests:
-
Select paths in the grid that have no test coverage.
-
Click Generate Test.
-
Define the test name or use the default name.
Tests are created for the paths. The new tests are added to the path's Covered by test column.
The test scripts consist of the units included in the path.
Create a test suite
To run MBT tests, you need to assign them to a test suite that serves as a container for your tests. You can create a new suite if needed, or assign them to an existing suite.
To create a test suite:
-
In a model, select the Tests tab.
-
Select the tests that you want to include in the test suite.
-
Right-click the tests you have selected, and select Create test suite.
If you have already created a test suite, you can add tests using the menu command Add to test suite.
-
Set the test suite attributes.
In particular, we recommend that you provide a value for the Backlog coverage and Application modules attributes. In Backlog coverage, for example, you can specify which features are covered by this suite's tests.
To add tests to a test suite in the Quality module:
-
In a test suite, select the Planning tab.
-
Click Add Existing Tests.
-
Select the MBT tests you want to include, and click Add.
Configure test details
After you create a test, you can configure optional details and review the test script.
To configure test details:
-
In a test, open the Details tab.
-
Enter any optional information that you want added to the test, such as test type, tags to help with filtering, or related backlog items and application modules.
The following custom fields can also be useful:
Field Description Path The names of the units that build the test path. Number of units The number of units in the path. Is valid on model This indicates if the model has changed and the test path is no longer valid. Testing tool type Defines which automated testing tool executes the test. Test runner Defines which test runner is used by the testing tool. For details, see Configure MBT. -
The Relations tab shows which items the test is automatically related to, including modules, units, and test suites. Click Add relation to link the test to a defect or requirement document.
-
The Script tab shows details regarding all the units that are included in the test, in the order that they are tested.
In the Test path pane, you can see the path of all the units included in the test. The current test path is bold, while other paths are grayed out.
-
Select a unit in the Script tab to see its location in the Test path. A tooltip shows details of each unit, enabling you to click through directly to the unit.
Configure parameters and data sets
The test's Parameters tab shows all the parameters that are defined in the test's units. A unit can have both input and output parameters, as described in Model units.
You can merge parameters that have the same value. For example, a business analyst may identify that the parameter User in one unit has the same value as User name in another, and they can be merged.
You can also link between parameters, so that the value of one output parameter is used as the input value of the next input parameter.
In the Data set tab, you define the test data that is used when running the test, for each of the parameters.
To merge parameters:
-
In a test, open the Parameters tab.
-
Select each of the parameters you want to merge, and then click Merge.
The original parameters are removed from the data set table. A new parameter is added named Merge <merge number>.
-
Click the new parameter name and rename it.
You can see the pre-merge names in the Original parameters field. The Used by field shows all the units where the merged parameter is included.
-
Click a merged parameter to see all of its related units highlighted in the Test path pane.
-
If you need to undo a merge, select the merged parameter and click Split.
To link between output and input parameters:
-
In a test, open the Parameters tab.
-
Select an output parameter that you want to link.
-
Select one or more subsequent input parameters, and click Link.
A link icon now appears next to the input parameter, and its Source field now contains the name of the output parameter it is linked to.
Note: You cannot link between an early input unit and a subsequent output unit.
-
If you need to undo a link, select the input parameter and click Unlink.
To create a data set:
-
In a test, open the Data set tab. This contains a table where each column represents a parameter in the test, and each row represents an iteration of one set of data to be used in the test.
-
Enter the data you want to use in the test's parameters.
Alternatively, access the More > Import Set menu command, and select a data set that you have saved in csv format.
When you run the test, each row in the table is used in one test run. For example, if you have 10 rows the test runs 10 times.
See also: