Skip to content

Commit 73e46c1

Browse files
committed
docs(README.md): optimize text in README to make it clearer
1 parent 0b96567 commit 73e46c1

6 files changed

Lines changed: 37 additions & 10 deletions

File tree

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.png filter=lfs diff=lfs merge=lfs -text
2+
*.gif filter=lfs diff=lfs merge=lfs -text

README.md

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<img style="margin: 20px;max-width: 68%" src="https://docs.balder.dev/en/latest/_static/balder_w_boarder.png" alt="Balder logo">
44
</div>
55

6-
Balder is a Python test system that allows you to reuse test code written once for different but similar product
7-
versions or variations. By separating the test logic from the product-specific implementation, it allows you to
8-
**adapt entire test suites to new devices or technologies in minutes** - even if they use completely different
9-
underlying mechanisms.
6+
Balder is a Python test system that allows you to reuse test code written once for different product versions or
7+
variations, without any code duplicates. By separating the test logic from the product-specific implementation, it
8+
allows you to **adapt entire test suites to new devices or technologies in minutes** - even if they use completely
9+
different underlying mechanisms.
1010

1111
This enables you to **install ready-to-use test cases** and provides various test development features that
1212
helps to test software or embedded devices much faster.
@@ -27,7 +27,7 @@ python -m pip install baldertest
2727

2828
# Run Balder
2929

30-
After you've installed it, you can run Balder with the following command:
30+
After you've installed it, you can run Balder with the following command:
3131

3232
```
3333
balder
@@ -55,8 +55,11 @@ mappings between Scenarios and Setups, generating and running variations dynamic
5555
Scenarios use inner Device classes to outline required devices and their features. Features are abstract classes
5656
defining interfaces (e.g., methods like `switch_on()`).
5757

58-
Here's an example Scenario for testing a light source's basic functionality, making it adaptable to any light-emitting
59-
device:
58+
Let's create a new scenario with two devices. One device emitting light and another device that detects light:
59+
60+
![light_expl_scenario.svg](doc/source/_static/light_expl_scenario.png)
61+
62+
Here's an implementation of this Scenario:
6063

6164
```python
6265
import balder
@@ -74,6 +77,8 @@ class ScenarioLight(balder.Scenario):
7477
class LightDetectingDevice(balder.Device):
7578
detector = BaseLightDetectorFeature()
7679

80+
# TEST METHOD: needs to start with `test_*` and is defined in scenarios only
81+
# -> can use all scenario device features
7782
def test_check_light(self):
7883
self.LightSpendingDevice.light.switch_on()
7984
assert self.LightDetectingDevice.detector.light_is_on()
@@ -90,14 +95,20 @@ This Scenario requires two devices: one to emit light and one to detect it. The
9095

9196
`BaseLightDetectorFeature`: Abstract feature with methods like `light_is_on()`.
9297

98+
Both devices are connected to each other (defined with the `@balder.connect(..)`), because the light-emitting device
99+
and the light detecting device need to interact somehow.
93100

94101
## Define the `Setup` class
95102

96103
Next step is defining a `Setup` class that describes what **we have**. For a `Scenario` to match a
97104
`Setup`, every feature required by the Scenario must exist as a subclass within the corresponding mapped Device in the
98105
Setup.
99106

100-
For testing a car with a light in a garage setup:
107+
For testing a car with a light in a garage setup `SetupGarage`:
108+
109+
![light_expl_setup.svg](doc/source/_static/light_expl_setup.png)
110+
111+
In code, this looks like:
101112

102113
```python
103114
import balder
@@ -118,7 +129,17 @@ class SetupGarage(balder.Setup):
118129

119130
```
120131

121-
Balder scans for matches: It checks if Setup devices implement all required Scenario features. In our case, it finds
132+
Note that `CarLightFeature` is a subclass of `BaseLightSpendingFeature` and `LightDetectorFeature` is a subclass of
133+
`BaseLightDetectorFeature`.
134+
135+
Balder scans for possible matches by checking whether a setup device provides implementations for all the features
136+
required by a candidate scenario device. When Balder identifies a valid variation - meaning every scenario device is
137+
mapped to a setup device that implements all the necessary scenario features - it executes the tests using that
138+
variation.
139+
140+
![light_expl_setup_garage_caronly.gif](doc/source/_static/light_expl_setup_garage_caronly.gif)
141+
142+
In our case, it finds
122143
one matching variation (`LightSpendingDevice -> Car | LightDetectingDevice -> Sensor`) and runs the test with it.
123144

124145
```shell
@@ -144,7 +165,8 @@ Now the big advantage of Balder comes into play. We can run our test with all de
144165
`BaseLightSpendingFeature`, independent of how this will be implemented in detail.
145166
**You do not need to rewrite the test**.
146167

147-
So, We have more devices in our garage. So let's add them:
168+
So, we have more devices in our garage. So let's add them:
169+
148170

149171
```python
150172
import balder
@@ -183,6 +205,9 @@ in both variants.
183205

184206
Balder now detects the two variations (`Car` and `Bicycle` as light sources):
185207

208+
![light_expl_setup_garage_full.gif](doc/source/_static/light_expl_setup_garage_full.gif)
209+
210+
Running Balder looks like shown below:
186211

187212
```shell
188213
+----------------------------------------------------------------------------------------------------------------------+
479 KB
Loading
670 KB
Loading
427 KB
Loading
667 KB
Loading

0 commit comments

Comments
 (0)