From: David ‘Bombe’ Roden Date: Sat, 8 Feb 2020 23:53:44 +0000 (+0100) Subject: ✅ Don’t run some tests in parallel X-Git-Tag: v81^2~5^2~3 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=d673c44ae56fcaf8368bcf3488f417e3b947158e;p=Sone.git ✅ Don’t run some tests in parallel --- diff --git a/build.gradle b/build.gradle index 78c3110..e5eaff7 100644 --- a/build.gradle +++ b/build.gradle @@ -57,8 +57,23 @@ dependencies { apply from: 'version.gradle' -test { +task parallelTest(type: Test) { maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 + useJUnit { + excludeCategories 'net.pterodactylus.sone.test.NotParallel' + } +} + +task notParallelTest(type: Test) { + maxParallelForks = 1 + useJUnit { + includeCategories 'net.pterodactylus.sone.test.NotParallel' + } +} + +test { + exclude '**' + dependsOn parallelTest, notParallelTest } task fatJar(type: Jar) { diff --git a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt index 1a71f4b..c628334 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt @@ -17,6 +17,7 @@ import net.pterodactylus.util.config.* import net.pterodactylus.util.version.Version import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* +import org.junit.experimental.categories.* import org.mockito.Mockito.* import java.io.* import java.util.concurrent.* @@ -25,6 +26,7 @@ import kotlin.test.* const val versionString = "v80" +@Category(NotParallel::class) class SoneModuleTest { private val currentDir: File = File(".") diff --git a/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt index e658fe2..0bb03af 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt @@ -15,6 +15,7 @@ import net.pterodactylus.sone.web.* import net.pterodactylus.sone.web.notification.* import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* +import org.junit.experimental.categories.* import org.mockito.Mockito.* import java.io.* import java.util.concurrent.atomic.* @@ -24,6 +25,7 @@ import kotlin.test.* * Unit test for [SonePlugin]. */ @Dirty +@Category(NotParallel::class) class SonePluginTest { private var sonePlugin = SonePlugin { injector } diff --git a/src/test/kotlin/net/pterodactylus/sone/test/NotParallel.kt b/src/test/kotlin/net/pterodactylus/sone/test/NotParallel.kt new file mode 100644 index 0000000..6e00fbf --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/sone/test/NotParallel.kt @@ -0,0 +1,8 @@ +package net.pterodactylus.sone.test + +/** + * Marker class for a JUnit [org.junit.experimental.categories.Category], to + * mark tests that should not be run parallel to other tests. + */ +class NotParallel +