Skip to content

Commit

Permalink
Merge pull request #13 from asarkar/issue-12
Browse files Browse the repository at this point in the history
Fix issue-12: Parameter injection of Resources does not clean up
  • Loading branch information
asarkar authored Sep 12, 2022
2 parents 897d0d6 + 4a2d7e9 commit f861bd7
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 12 deletions.
8 changes: 8 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,11 @@ nexusPublishing {
}
}
}

tasks.withType<Test> {
useJUnitPlatform()
testLogging {
showStandardStreams = true
}
exclude("**/ignore/**")
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ktlintVersion=10.2.1
nexusPluginVersion=1.1.0

projectGroup=com.asarkar.grpc
projectVersion=1.2.1
projectVersion=1.2.2
projectDescription=JUnit5 Extension that can automatically release gRPC resources at the end of the test
licenseName=Apache-2.0
licenseUrl=http://www.apache.org/licenses/LICENSE-2.0.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ class GrpcCleanupExtension :
parameterCtx.declaringExecutable.isAnnotationPresent(BeforeAll::class.java)
)

return Resources().also { extensionCtx.resources.getOrPut(once, { mutableListOf() }).add(it) }
return Resources().also { resources ->
extensionCtx.resources = extensionCtx.resources.also {
it.getOrPut(once) { mutableListOf() }.add(resources)
}
}
}

override fun beforeAll(ctx: ExtensionContext) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package com.asarkar.grpc.test

import com.asarkar.grpc.test.ignore.ExampleTestCase
import com.asarkar.grpc.test.ignore.ExampleTestCase10
import com.asarkar.grpc.test.ignore.ExampleTestCase2
import com.asarkar.grpc.test.ignore.ExampleTestCase3
import com.asarkar.grpc.test.ignore.ExampleTestCase4
import com.asarkar.grpc.test.ignore.ExampleTestCase5
import com.asarkar.grpc.test.ignore.ExampleTestCase6
import com.asarkar.grpc.test.ignore.ExampleTestCase7
import com.asarkar.grpc.test.ignore.ExampleTestCase8
import com.asarkar.grpc.test.ignore.ExampleTestCase9
import io.grpc.ManagedChannel
import io.grpc.Server
import org.assertj.core.api.Assertions.assertThat
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.asarkar.grpc.test
package com.asarkar.grpc.test.ignore

import com.asarkar.grpc.test.GrpcCleanupExtension
import com.asarkar.grpc.test.Resources
import io.grpc.ManagedChannel
import io.grpc.Server
import org.junit.jupiter.api.Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.asarkar.grpc.test
package com.asarkar.grpc.test.ignore

import com.asarkar.grpc.test.GrpcCleanupExtension
import com.asarkar.grpc.test.Resources
import com.asarkar.grpc.test.TestUtils
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.BeforeEach
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.asarkar.grpc.test
package com.asarkar.grpc.test.ignore

import com.asarkar.grpc.test.GrpcCleanupExtension
import com.asarkar.grpc.test.Resources
import com.asarkar.grpc.test.TestUtils
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.asarkar.grpc.test
package com.asarkar.grpc.test.ignore

import com.asarkar.grpc.test.GrpcCleanupExtension
import com.asarkar.grpc.test.Resources
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.extension.ExtendWith
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.asarkar.grpc.test
package com.asarkar.grpc.test.ignore

import com.asarkar.grpc.test.GrpcCleanupExtension
import com.asarkar.grpc.test.Resources
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.asarkar.grpc.test
package com.asarkar.grpc.test.ignore

import com.asarkar.grpc.test.GrpcCleanupExtension
import com.asarkar.grpc.test.Resources
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.asarkar.grpc.test
package com.asarkar.grpc.test.ignore

import com.asarkar.grpc.test.GrpcCleanupExtension
import com.asarkar.grpc.test.Resources
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.asarkar.grpc.test
package com.asarkar.grpc.test.ignore

import com.asarkar.grpc.test.GrpcCleanupExtension
import com.asarkar.grpc.test.Resources
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.extension.ExtendWith
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.asarkar.grpc.test
package com.asarkar.grpc.test.ignore

import com.asarkar.grpc.test.GrpcCleanupExtension
import com.asarkar.grpc.test.Resources
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.asarkar.grpc.test
package com.asarkar.grpc.test.ignore

import com.asarkar.grpc.test.GrpcCleanupExtension
import com.asarkar.grpc.test.Resources
import com.asarkar.grpc.test.TestUtils
import io.grpc.ManagedChannel
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeAll
Expand Down

0 comments on commit f861bd7

Please sign in to comment.