Skip to content

Commit 716aff3

Browse files
committed
test: behaviour of IF_SUCCESSFUL for groups with failing tests
1 parent 1b9c7ba commit 716aff3

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/test/kotlin/DefaultTestFilesSpec.kt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ object DefaultTestFilesSpec: Spek({
330330
expect(failureTestdir).existsNot()
331331
}
332332

333-
it("deletes a file that has been marked to be deleted after success if appropriate") {
333+
it("deletes a file that has been marked to be deleted IF_SUCCESSFUL only if a test was successful") {
334334
val mockTest = mockScope<TestScopeImpl>("delete IF_SUCCESSFUL")
335335

336336
testFiles.beforeExecuteTest(mockTest)
@@ -353,6 +353,28 @@ object DefaultTestFilesSpec: Spek({
353353
expect(failureTestdir).exists()
354354
}
355355

356+
it("does not delete a group file that has been marked to be deleted IF_SUCCESSFUL if a test in the group failed") {
357+
val mockGroup = mockScope<GroupScopeImpl>("delete IF_SUCCESSFUL group")
358+
val mockTest = mockScope<TestScopeImpl>("delete IF_SUCCESSFUL test")
359+
360+
testFiles.beforeExecuteGroup(mockGroup)
361+
val successGroupTestfile = testFiles.createFile(delete = IF_SUCCESSFUL)
362+
val successGroupTestdir = testFiles.createDirectory(delete = IF_SUCCESSFUL)
363+
364+
testFiles.beforeExecuteTest(mockTest)
365+
val successTestTestfile = testFiles.createFile(delete = IF_SUCCESSFUL)
366+
val successTestTestdir = testFiles.createDirectory(delete = IF_SUCCESSFUL)
367+
368+
val ifSuccessFiles = listOf(successGroupTestfile, successGroupTestdir, successTestTestfile, successTestTestdir)
369+
ifSuccessFiles.forEach { expect(it).exists() }
370+
371+
testFiles.afterExecuteTest(mockTest, Failure(IllegalStateException()))
372+
ifSuccessFiles.forEach { expect(it).exists() }
373+
374+
testFiles.afterExecuteGroup(mockGroup, Success)
375+
ifSuccessFiles.forEach { expect(it).exists() }
376+
}
377+
356378
it("does not delete a file that has been marked to be deleted NEVER") {
357379
val mockTest = mockScope<TestScopeImpl>("delete NEVER")
358380

0 commit comments

Comments
 (0)