Skip to content

Commit

Permalink
Use simpler random generator
Browse files Browse the repository at this point in the history
  • Loading branch information
3750 committed Nov 14, 2023
1 parent f941baa commit ea19a64
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
34 changes: 32 additions & 2 deletions part1.0-introduction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ runner {
- for features (tests methods) by `runner.parallel.defaultExecutionMode`

Sample configuration:

```groovy
import org.spockframework.runtime.model.parallel.ExecutionMode
Expand All @@ -61,6 +62,7 @@ runner {
}
}
```

- or

```groovy
Expand All @@ -87,6 +89,18 @@ runner {
```groovy
import org.spockframework.runtime.model.parallel.ExecutionMode
runner {
parallel {
enabled true
}
}
```

- or

```groovy
import org.spockframework.runtime.model.parallel.ExecutionMode
runner {
parallel {
enabled true
Expand Down Expand Up @@ -166,12 +180,29 @@ Supported options:

Default: `dynamicWithReservedProcessors(1.0, 2)` (`Runtime.getRuntime().availableProcessors() * 1.0 - 2`)

Example thread pool configuration:

```groovy
runner {
parallel {
enabled true
fixed(4)
}
}
```

Check number of available processors:

```sh
jshell print-available-processors.jsh
```

Sample output:

```
Runtime.getRuntime().availableProcessors() = 10
```

- Add test case to class `A`

```groovy
Expand All @@ -187,13 +218,12 @@ def "test 3"() {
```

- Remove class `C`

- Run
tests `./gradlew --rerun-tasks :part1.0-introduction:test :part1.0-introduction:createTestsExecutionReport -PtotalTimeOfAllTests=false`
- Check [reports](build/reports/tests-execution/html/test.html)
- Configure a thread pool of your choice, run tests and check reports
- Randomize duration of tests. In test `test 3` replace `SLEEP_DURATION`
with `org.apache.commons.lang3.RandomUtils.nextInt(50, 250)`. Run tests and check reports.
with `new Random().nextLong(50, 250)`. Run tests and check reports.

---

Expand Down
1 change: 0 additions & 1 deletion part1.0-introduction/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ dependencies {
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

testImplementation 'org.spockframework:spock-core:2.4-M1-groovy-4.0'
testImplementation 'org.apache.commons:commons-lang3:3.13.0'
}

test {
Expand Down

0 comments on commit ea19a64

Please sign in to comment.