Skip to content

Commit

Permalink
chore: format tab view
Browse files Browse the repository at this point in the history
  • Loading branch information
alestiago committed Sep 3, 2024
1 parent b025f2f commit a391af5
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/content/docs/testing/testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ Tests should not share state between them to ensure they remain independent, rel

When tests share state—such as variables, test's outcome and order can influence another's, leading to inconsistent results and making it difficult to identify the root cause of failures.


<Tabs>
<TabItem label="Good ✅">
```dart
Expand All @@ -436,8 +435,8 @@ class _Counter {
}
void main() {
group(_Counter, () {
late _Counter counter;
group(\_Counter, () {
late \_Counter counter;
setUp(() => counter = _Counter());
Expand All @@ -450,10 +449,11 @@ void main() {
counter.decrement();
expect(counter.value, -1);
});
});
});
}
```
````
</TabItem>
<TabItem label="Bad ❗️">
```dart
Expand All @@ -480,7 +480,8 @@ void main() {
});
}
```
````
</TabItem>
</Tabs>
Expand All @@ -494,15 +495,15 @@ By running tests in random order, these hidden dependencies are more likely to b
This practice ensures that tests do not share state or rely on the side effects of previous tests, leading to a more robust and reliable test suite. Overall, the tests become easier to trust and reduce debugging time caused by intermittent test failures.

<Tabs>
<TabItem label="Good ✅">
```sh
# Randomize test ordering using the --test-randomize-ordering-seed option
flutter test --test-randomize-ordering-seed random
dart test --test-randomize-ordering-seed random
very_good test --test-randomize-ordering-seed
very_good test --test-randomize-ordering-seed
```

</TabItem>
</Tabs>
</Tabs>

0 comments on commit a391af5

Please sign in to comment.