Skip to content

Commit

Permalink
Simplify tests in part 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
3750 committed Nov 14, 2023
1 parent ea19a64 commit ad7ecf3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
8 changes: 2 additions & 6 deletions part1.1-shared-state/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ Some tests failed. Eliminate shared state by using different `name` in test case
Sample output:

```text
name = testName 3 readable: false
name = testName 3 readable: true
name = testName 3
name = testName 1
name = testName 2
```
Expand All @@ -136,7 +135,6 @@ Sample output:
name = BM8LX
name = Kbc28
name = boR1b
name = 7Oc3i
```

### Approach no. 3
Expand All @@ -153,7 +151,6 @@ Sample output:
name = 3
name = 1
name = 2
name = 4
```

### Approach no. 4
Expand All @@ -167,8 +164,7 @@ name = 4
Sample output:

```text
name = pl.allegro.tech.workshops.testsparallelexecution:SharedStateExampleTest:should create readable - non-readable file [readable: true, #0]
name = pl.allegro.tech.workshops.testsparallelexecution:SharedStateExampleTest:should create readable - non-readable file [readable: false, #1]
name = pl.allegro.tech.workshops.testsparallelexecution:SharedStateExampleTest:should remove file
name = pl.allegro.tech.workshops.testsparallelexecution:SharedStateExampleTest:should create dir
name = pl.allegro.tech.workshops.testsparallelexecution:SharedStateExampleTest:should create file
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class SharedStateExampleTest extends Specification {
println "name = $name"

when:
def fileCreated = file.createNewFile()
def fileWasCreated = file.createNewFile()

then:
fileCreated
fileWasCreated
file.exists()
}

Expand All @@ -41,31 +41,26 @@ class SharedStateExampleTest extends Specification {
println "name = $name"

when:
def fileCreated = file.mkdir()
def directoryWasCreated = file.mkdir()

then:
fileCreated
directoryWasCreated
file.exists()
}

def "should create readable or non-readable file"() {
def "should remove file"() {
given:
name = "testName"
file = new File(tempDir, name)
file.setReadable(readable)
assert file.createNewFile()
println "name = $name"

when:
def fileCreated = file.createNewFile()
def fileWasDeleted = file.delete()

then:
fileCreated
file.exists()

where:
readable | _
true | _
false | _
fileWasDeleted
!file.exists()
}

}

0 comments on commit ad7ecf3

Please sign in to comment.