Skip to content

Commit ef57464

Browse files
committed
test: use defaultTestCaseConfig instead of @EnabledIf
- simpler code - display skip info when run test
1 parent c202a3d commit ef57464

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

tool/src/test/java/com/alibaba/dcm/tool/DcmToolTests.kt

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
package com.alibaba.dcm.tool
22

33
import io.kotest.assertions.fail
4-
import io.kotest.core.annotation.EnabledCondition
5-
import io.kotest.core.annotation.EnabledIf
6-
import io.kotest.core.spec.Spec
74
import io.kotest.core.spec.style.AnnotationSpec
5+
import io.kotest.core.test.config.TestCaseConfig
86
import io.kotest.matchers.shouldBe
97
import org.apache.commons.io.FileUtils
108
import org.apache.commons.lang3.SystemUtils
119
import org.apache.maven.artifact.versioning.ComparableVersion
1210
import java.io.File
1311
import java.net.InetAddress
14-
import kotlin.reflect.KClass
1512
import kotlin.streams.toList
1613

1714
/**
1815
* https://kotest.io/docs/framework/testing-styles.html#annotation-spec
1916
*
2017
* @author Jerry Lee (oldratlee at gmail dot com)
2118
*/
22-
// Ignore "attach to current VM" test for jdk 9+, since java 9+ does not support
23-
// "java.io.IOException: Can not attach to current VM"
24-
@EnabledIf(Java8Only::class)
2519
class DcmToolTests : AnnotationSpec() {
2620

21+
// Ignore "attach to current VM" test for jdk 9+, since java 9+ does not support
22+
// "java.io.IOException: Can not attach to current VM"
23+
@Suppress("OverridingDeprecatedMember")
24+
override fun defaultTestCaseConfig(): TestCaseConfig =
25+
TestCaseConfig(enabled = SystemUtils.IS_JAVA_1_8)
26+
2727
private lateinit var agentFilePath: String
2828

2929
@BeforeAll
@@ -98,10 +98,3 @@ class DcmToolTests : AnnotationSpec() {
9898
return !replaced.contains("-")
9999
}
100100
}
101-
102-
/**
103-
* https://kotest.io/docs/framework/conditional/spec-annotations-conditional-evaluation.html
104-
*/
105-
class Java8Only : EnabledCondition {
106-
override fun enabled(kclass: KClass<out Spec>): Boolean = SystemUtils.IS_JAVA_1_8
107-
}

0 commit comments

Comments
 (0)