In this part you will learn and exercise techniques of eliminating shared state modifications in tests. This allows to migrate tests from sequential to parallel execution.
First, familiarize yourself with code in this module.
-
Run tests
./gradlew --rerun-tasks :part1.2-from-sequential-to-parallel:test :part1.2-from-sequential-to-parallel:createTestsExecutionReport --continue
-
Check reports
-
Enable parallel execution in
SpockConfig.groovy
-
Run tests again
./gradlew --rerun-tasks :part1.2-from-sequential-to-parallel:test :part1.2-from-sequential-to-parallel:createTestsExecutionReport --continue
Some tests failed. Let's fix it step by step.
- Add
@Isolated
(spock.lang.Isolated
) toAppendTextSpec class
,SetTextSpec class
,MetricsSpec class
andRemoveFileSpec class
- Run
tests
./gradlew --rerun-tasks :part1.2-from-sequential-to-parallel:test :part1.2-from-sequential-to-parallel:createTestsExecutionReport --continue
- Check reports
- Repeat:
- Remove
@Isolated
in one class (start withAppendTextSpec class
, thenSetTextSpec class
andRemoveFileSpec class
) - Fix tests
- Run
tests
./gradlew --rerun-tasks :part1.2-from-sequential-to-parallel:test :part1.2-from-sequential-to-parallel:createTestsExecutionReport --continue
- Check reports
- Remove