Skip to content

Commit 8899f1c

Browse files
committed
ASSERT is always used, no explanation for EXPECT was given.
1 parent 93f52b6 commit 8899f1c

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

mevislab.github.io/content/tutorials/summary/summary4.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ MATE automatically opens the Python file of your test case and it appears in MeV
6464

6565
### Write Test Functions in Python
6666

67+
{{<alert class="info" caption="Info">}}
68+
In this example, we are using the **ASSERT*** functionalities, becase they throw an exception in case the expected value does not match the actual value. Your test execution stops in this case.
69+
70+
You can also use **EXPECT*** functions. They return *true* or *false* and you can decide yourself ho your test continues.
71+
72+
For details, see {{< docuLinks "/Resources/Documentation/Publish/SDK/TestCenterReference/namespaceTestSupport_1_1Macros.html" "TestCenter Reference" >}}
73+
{{</alert>}}
74+
6775
#### Preparations
6876
Before writing a test case, we need some helper functions in Python, which we will use in our test cases. The first thing we need is a function to load images.
6977

mevislab.github.io/content/tutorials/testing/testingexample1.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ menu:
2020
## Introduction
2121
In this example you will learn how to write an automated test for a simple network using the `DicomImport`, `MinMaxScan`, and `View3D` modules. Afterward, you will be able to write test cases for any other module and network yourself.
2222

23+
MeVisLab provides two options to compare a test result with an expected result:
24+
#### ASSERT
25+
Multiple **ASSERT_*** functions to compare expected and actual result are available, for example **ASSERT_EQ()** (check if two values are equal) or **ASSERT_GT()** (check if value is greater than another value).
26+
27+
In case an assertion fails, an exception is thrown and the test execution stops.
28+
#### EXPECT
29+
The same comparisons can be done by using **EXPECT_***. The functions return *true* or *false* and depending on the result you can decide how to proceed.
30+
31+
Make sure to use the right comparison methods depending on your needs.
32+
33+
{{<alert class="info" caption="Info">}}
34+
Additional information can be found in {{< docuLinks "/Resources/Documentation/Publish/SDK/TestCenterReference/namespaceTestSupport_1_1Macros.html" "TestCenter Reference" >}}
35+
{{</alert>}}
36+
2337
## Steps to Do
2438

2539
### Creating the Network to be Used for Testing
@@ -87,6 +101,8 @@ When *ready* is true, the test touches the *selectNextItem* trigger, so that the
87101

88102
The value of our `DicomImport`s *progress* field is saved as the *currentValue* variable and compared to the *expectedValue* variable by calling *ASSERT_FLOAT_EQ(expectedValue,currentValue)* to determine if the DICOM import has finished (*currentValue* and *expectedValue* are equal) or not.
89103

104+
You can play around with the differences between **ASSERT_FLOAT_EQ()** and **EXPECT_FLOAT_EQ()** and le your test fail to see the differences.
105+
90106
### Run Your Test Case
91107
Open the TestCase Manager und run your test by selecting your test case and clicking on the *Play* button in the bottom right corner.
92108

@@ -126,5 +142,7 @@ Create a global macro module and implement the following test objectives for bot
126142
* MeVisLab provides a TestCenter for writing automated tests in Python.
127143
* Tests can be executed on networks and macro modules.
128144
* The test results are shown in a ReportViewer.
145+
* **ASSERT*** functions throw an exception if the expected result differs from the actual result. The test run is aborted in such a case.
146+
* **EXPECT*** functions return *true* or *false*. You can decide yoursel how to continue your test.
129147

130148
{{< networkfile "examples/testing/example1/TestCases.zip" >}}

mevislab.github.io/content/tutorials/testing/testingexample3.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ def testPatient(path, windowCenter):
8585
4. The final test functions *ASSERT_EQ* evaluate if the given values are equal.
8686

8787
{{<alert class="info" caption="Info">}}
88-
You can use many other *ASSERT** possibilities, just try using the MATE autocompletion and play around with them.
88+
You can use many other **ASSERT*** possibilities, just try using the MATE autocompletion and play around with them. **ASSERT*** functions throw an exception in case expected and actul values do not fit. Your test execution stops in this case.
89+
90+
You can also use **EXPECT*** functions. They return *true* or *false* and you can decide yourself ho your test continues.
91+
92+
For details, see {{< docuLinks "/Resources/Documentation/Publish/SDK/TestCenterReference/namespaceTestSupport_1_1Macros.html" "TestCenter Reference" >}}
8993
{{</alert>}}
9094

9195
### Run Your Iterative Test

0 commit comments

Comments
 (0)