Skip to content

Commit d644f95

Browse files
committed
Rework intro slides of Chapter 5: Testing and CI
1 parent 2cdc2d7 commit d644f95

File tree

2 files changed

+45
-41
lines changed

2 files changed

+45
-41
lines changed

05_testing_and_ci/intro_slides.md

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ slideOptions:
2929

3030
## Learning Goals of the Chapter
3131

32-
- Explain why developing tests is crucial.
32+
- Explain the importance of writing tests for simulation software.
3333
- Explain the concepts of unit testing, integration testing and regression testing with the perspective of simulation software.
3434
- Write tests using the Python libraries `pytest` and `unittest`.
3535
- Write tests in C++ using `Boost.Test`.
@@ -41,35 +41,36 @@ slideOptions:
4141
## What is Testing?
4242

4343
- Smelling old milk before using it!
44-
- A way to determine if a software is not producing reliable results and if so, what is the reason.
45-
- Manual testing vs. Automated testing.
44+
- A method to ensure that a software is producing reliable results.
45+
- Manual testing vs. automated testing.
4646

4747
---
4848

4949
## Why Should you Test your Software?
5050

51-
- Improve software reliability and reproducibility.
52-
- Make sure that changes (bugfixes, new features) do not affect other parts of software.
53-
- Generally all software is better off being tested regularly. Possible exceptions are very small codes with single users.
54-
- Ensure that a distributed/packaged software actually works.
51+
- Catch errors before software use in the real world.
52+
- Improve software reliability.
53+
- Make sure that changes (bugfixes, features) do not introduce bugs.
54+
- All software is better off being tested regularly. Exceptions could be very small codes with single users.
55+
- Packaged version works as expected.
5556

5657
---
5758

5859
## Nomenclature in Software Testing
5960

60-
- **Fixture**: preparatory set for testing.
61-
- **Actual result**: what the code produces when given the fixture.
62-
- **Expected result**: what the actual result is compared to.
63-
- **Test coverage**: how much of the code do tests touch in one run.
61+
- **Fixture**: preparatory definitions for testing.
62+
- **Actual result**: what the software produces with the fixture.
63+
- **Expected result**: ground truth or true result.
64+
- **Test coverage**: how much of the software do tests run through.
6465

6566
---
6667

6768
## Some Ways to Test Software
6869

6970
- Assertions
70-
- Unit testing
71-
- Integration testing
72-
- Regression testing
71+
- Unit tests
72+
- Integration tests
73+
- Regression tests
7374

7475
---
7576

@@ -78,70 +79,68 @@ slideOptions:
7879
- Principle of *defensive programming*.
7980
- Nothing happens when an assertion is true; throws error when false.
8081
- Types of assertion statements:
81-
- Precondition
82-
- Postcondition
83-
- Invariant
82+
- Precondition: something that must be true at the start.
83+
- Postcondition: something that is true after execution.
84+
- Invariant: something that is always true.
8485
- A basic but powerful tool to test a software on-the-go.
85-
- Assertion statement syntax in Python
86+
- Assertion statement syntax in Python:
8687

8788
```python
8889
assert condition, "message"
8990
```
9091

9192
---
9293

93-
## Unit Testing
94+
## Unit Tests
9495

9596
- Catching errors with assertions is good but preventing them is better!
9697
- A *unit* is a single function in one situation.
9798
- A situation is one amongst many possible variations of input parameters.
98-
- User creates the expected result manually.
99-
- A fixture is a set of inputs used to generate an actual result.
99+
- Expected result is created manually.
100100
- Actual result is compared to the expected result, for e.g. using an assertion statement.
101101

102102
---
103103

104-
## Integration Testing
104+
## Integration Tests
105105

106106
- Test whether several units work in conjunction.
107107
- *Integrate* units and test them together in an *integration* test.
108108
- Often more complicated than a unit test and has more test coverage.
109-
- A fixture is used to generate an actual result.
110109
- Actual result is compared to the expected result, for e.g. using an assertion statement.
111110

112111
---
113112

114-
## Regression Testing
113+
## Regression Tests
115114

116-
- Generating an expected result is not possible in some situations.
115+
- Generating an expected result is not always possible.
117116
- Compare the current actual result with a previous actual result.
118117
- No guarantee that the current actual result is correct.
119-
- Risk of a bug being carried over indefinitely.
120-
- Main purpose is to identify changes in the current state of the code with respect to a past state.
118+
- Does not catch long-existing bugs.
119+
- Compare changes in the current state of the software with respect to a past (reliable) state.
121120

122121
---
123122

124123
## Test Coverage
125124

126-
- Coverage is the amount of code a test runs through.
125+
- Coverage is the amount of software that is run by running the tests.
127126
- Aim for high test coverage.
128-
- There is a trade-off: extremely high test coverage vs. effort in test development
127+
- Trade-off: extremely high test coverage vs. effort in test development
129128

130129
---
131130

132131
## Comparing Floating-point Variables
133132

134-
- Very often quantities in simulation software are `float` / `double`.
135-
- Such quantities cannot be compared to exact values, an approximation is necessary.
136-
- Comparison of floating point variables needs to be done to a certain tolerance.
133+
- Very often data in simulation software is of type `float` or `double`.
134+
- Such data cannot be compared to exact values, an approximation is necessary.
135+
- Comparing such data up to a certain tolerance.
137136
- In `pytest` there is `pytest.approx(value, abs=tol)`.
138137
- In `unittest` there is `assertAlmostEqual()`.
139138

140139
---
141140

142141
## Test-driven Development (TDD)
143142

144-
- Principle of writing a test and then write a code to fulfill the test.
143+
- Idea: write a test and then write part of the software to fulfill the test.
145144
- Advantages:
146145
- Leads to a robust test along with the implementation.
147146
- Eliminates confirmation bias of the user.
@@ -151,19 +150,15 @@ assert condition, "message"
151150
- False security from tests.
152151
- Neglect of overall design.
153152

154-
Source: https://en.wikipedia.org/wiki/Test-driven_development
153+
[TDD on Wikipedia](https://en.wikipedia.org/wiki/Test-driven_development)
155154

156155
---
157156

158157
## Verifying a Test
159158

160-
- Test written as part of a bug-fix:
161-
- Reproduce the bug in the test by ensuring that the test fails.
162-
- Fix the bug.
163-
- Rerun the test to ensure that it passes.
164-
- Test written to increase code coverage:
165-
- Make sure that the first iteration of the test passes.
166-
- Try introducing a small fixable bug in the code to verify if the test fails.
159+
- Reproduce the bug in the test by ensuring that the test fails.
160+
- Fix the bug.
161+
- Rerun the test to ensure that it passes.
167162

168163
---
169164

timetable.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,12 @@
112112
- **20** min.: [Versioning](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/06_miscellaneous/versioning_slides.md)
113113
- **20** min.: [Repository Layouts](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/06_miscellaneous/repository_layouts_slides.md)
114114
- **20** min.: [DOI, Zenodo, DaRUS](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/06_miscellaneous/doi_zenodo_darus_slides.md)
115+
116+
## 12.1 – Wed, January 14, 2026
117+
118+
- **20** min.: Introduction to Testing: [slides](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/05_testing_and_ci/intro_slides.md)
119+
- **70** min.: Testing Python Code: [slides](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/05_testing_and_ci/python_testing_slides.md), [demo](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/05_testing_and_ci/python_testing_demo.md)
120+
121+
## 12.2 – Wed, January 14, 2025
122+
123+
- **90** min.: [Exercise: Testing Python Code](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/05_testing_and_ci/python_testing_exercise.md)

0 commit comments

Comments
 (0)