Part 3: Testing with Faktor-IPS

Creating Test Cases by Copying them

In the following example we will show you how to create and customize new tests by simply copying them. We want to create a premium computation test for the product HC-Optimal 2021-12 instead of HC-Compact 2021-12.

To do this, we select the test case we want to copy - PremiumComputationTest1 - in the Model Explorer and call Copy Test Case…​ from the context menu.

CopyTestCase
Figure 1. Copy test case context menu

The wizard shown in the next figure guides us through the creation of the test case.

copy testcase
Figure 2. Copy test case wizard, Page 1

We give the test case a name and, using the radio button With different components, we decide that we want to replace the product components of the source test case by other product components. As we want our target test case to inherit the existing input values and the expected results, we leave both Copy test values checkboxes enabled and click Next > to confirm our settings.

We are now able to cancel or replace product components. In order to replace a product component we select it in the left pane of the the structure view. As a result, the list in the right-hand pane now displays all product components that are suitable for this relationship. We then select the new product component and replace HC-Compact 2021-12 by HC-Optimal 2021-12 and BaseCoverage-Compact 2021-12 by BaseCoverage-Optimal 2021-21, respectively.

replace product components
Figure 3. Replacing product components in a test copy

Once we click Finish to exit the wizard, the new test case will be created and opened in the Test Case Editor.

copied test
Figure 4. A copied test case

If we execute the test case, we get a deviation in our expected result because the HC-Optimal product has, among others, different premiums than HC-Compact. However, there is a simple means to accept the computed result as the expected result. We just have to click the Compute expected values icon: TestCaseRunAndStoreExpResult

The test case will now be run and the computed results will be imported in our test case. So this is a straightforward approach to determine the expected result and to construct a correct test case.

copied test computed
Figure 5. The computed values have been applied to the test case