Skip to content

Commit 69c3273

Browse files
committed
TS-38628 Update Mockito 4.11.0 -> 5.4.0 and Mockito Kotlin
1 parent 779dab1 commit 69c3273

File tree

4 files changed

+37
-38
lines changed

4 files changed

+37
-38
lines changed

buildSrc/src/main/kotlin/com.teamscale.java-convention.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dependencies {
3333
testImplementation(lib("assertj"))
3434
testImplementation(lib("mockito-core"))
3535
testImplementation(lib("mockito-junit"))
36+
testImplementation(lib("mockito-kotlin"))
3637

3738
testRuntimeOnly(lib("junit-platform-launcher"))
3839
testRuntimeOnly(lib("junit-jupiter-engine"))

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ retrofit = "2.11.0"
1212
junit = "5.11.3"
1313
junitPlatform = "1.11.3"
1414
okhttp = "4.12.0"
15-
mockito = "4.11.0"
15+
mockito = "5.12.0"
16+
mockitoKotlin = "5.4.0"
1617
picocli = "4.7.6"
1718

1819
[libraries]
@@ -75,6 +76,7 @@ jsonassert = { module = "org.skyscreamer:jsonassert", version = "1.5.3" }
7576

7677
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" }
7778
mockito-junit = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito" }
79+
mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockitoKotlin" }
7880

7981
springboot-loader = { module = "org.springframework.boot:spring-boot-loader", version = "3.4.0" }
8082

impacted-test-engine/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies {
1919

2020
compileOnly(libs.junit.platform.engine)
2121
compileOnly(libs.junit.platform.commons)
22-
testImplementation(libs.junit.platform.engine)
22+
testImplementation(libs.junit.platform.engine)
2323
testImplementation(libs.junit.jupiter.params)
24+
testImplementation(libs.mockito.kotlin)
2425
}

impacted-test-engine/src/test/kotlin/com/teamscale/test_impacted/engine/executor/TestwiseCoverageCollectingExecutionListenerTest.kt

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ import com.teamscale.test_impacted.test_descriptor.ITestDescriptorResolver
66
import org.assertj.core.api.Assertions
77
import org.junit.jupiter.api.Test
88
import org.junit.platform.engine.EngineExecutionListener
9-
import org.junit.platform.engine.TestDescriptor
109
import org.junit.platform.engine.TestExecutionResult
1110
import org.junit.platform.engine.UniqueId
12-
import org.mockito.ArgumentMatchers
13-
import org.mockito.Mockito
14-
import org.mockito.Mockito.mock
11+
import org.mockito.kotlin.*
1512
import java.util.*
1613

14+
@Suppress("INLINE_FROM_HIGHER_PLATFORM")
1715
/** Tests for [TestwiseCoverageCollectingExecutionListener]. */
1816
internal class TestwiseCoverageCollectingExecutionListenerTest {
17+
1918
private val mockApi = mock<TeamscaleAgentNotifier>()
2019

2120
private val resolver = mock<ITestDescriptorResolver>()
@@ -42,54 +41,50 @@ internal class TestwiseCoverageCollectingExecutionListenerTest {
4241
)
4342
val testRoot = SimpleTestDescriptor.testContainer(rootId, testClass)
4443

45-
Mockito.`when`(resolver.getUniformPath(impactedTestCase))
44+
whenever(resolver.getUniformPath(impactedTestCase))
4645
.thenReturn(Optional.of("MyClass/impactedTestCase()"))
47-
Mockito.`when`(resolver.getClusterId(impactedTestCase))
46+
whenever(resolver.getClusterId(impactedTestCase))
4847
.thenReturn(Optional.of("MyClass"))
49-
Mockito.`when`(resolver.getUniformPath(regularSkippedTestCase))
48+
whenever(resolver.getUniformPath(regularSkippedTestCase))
5049
.thenReturn(Optional.of("MyClass/regularSkippedTestCase()"))
51-
Mockito.`when`(resolver.getClusterId(regularSkippedTestCase))
50+
whenever(resolver.getClusterId(regularSkippedTestCase))
5251
.thenReturn(Optional.of("MyClass"))
5352

5453
// Start engine and class.
5554
executionListener.executionStarted(testRoot)
56-
Mockito.verify(executionListenerMock).executionStarted(testRoot)
55+
verify(executionListenerMock).executionStarted(testRoot)
5756
executionListener.executionStarted(testClass)
58-
Mockito.verify(executionListenerMock).executionStarted(testClass)
57+
verify(executionListenerMock).executionStarted(testClass)
5958

6059
// Execution of an impacted test case.
6160
executionListener.executionStarted(impactedTestCase)
62-
Mockito.verify(mockApi).startTest("MyClass/impactedTestCase()")
63-
Mockito.verify(executionListenerMock).executionStarted(impactedTestCase)
61+
verify(mockApi).startTest("MyClass/impactedTestCase()")
62+
verify(executionListenerMock).executionStarted(impactedTestCase)
6463
executionListener.executionFinished(impactedTestCase, TestExecutionResult.successful())
65-
Mockito.verify(mockApi).endTest(ArgumentMatchers.eq("MyClass/impactedTestCase()"), ArgumentMatchers.any())
66-
Mockito.verify(executionListenerMock).executionFinished(impactedTestCase, TestExecutionResult.successful())
64+
verify(mockApi).endTest(eq("MyClass/impactedTestCase()"), any())
65+
verify(executionListenerMock).executionFinished(impactedTestCase, TestExecutionResult.successful())
6766

6867
// Ignored or disabled impacted test case is skipped.
6968
executionListener.executionSkipped(regularSkippedTestCase, "Test is disabled.")
70-
Mockito.verify(executionListenerMock).executionSkipped(regularSkippedTestCase, "Test is disabled.")
69+
verify(executionListenerMock).executionSkipped(regularSkippedTestCase, "Test is disabled.")
7170

7271
// Finish class and engine.
7372
executionListener.executionFinished(testClass, TestExecutionResult.successful())
74-
Mockito.verify(executionListenerMock).executionFinished(testClass, TestExecutionResult.successful())
73+
verify(executionListenerMock).executionFinished(testClass, TestExecutionResult.successful())
7574
executionListener.executionFinished(testRoot, TestExecutionResult.successful())
76-
Mockito.verify(executionListenerMock).executionFinished(testRoot, TestExecutionResult.successful())
75+
verify(executionListenerMock).executionFinished(testRoot, TestExecutionResult.successful())
7776

78-
Mockito.verifyNoMoreInteractions(mockApi)
79-
Mockito.verifyNoMoreInteractions(executionListenerMock)
77+
verifyNoMoreInteractions(mockApi)
78+
verifyNoMoreInteractions(executionListenerMock)
8079

8180
val testExecutions = executionListener.testExecutions
8281

8382
Assertions.assertThat(testExecutions).hasSize(2)
8483
Assertions.assertThat(testExecutions).anySatisfy { testExecution: TestExecution ->
85-
Assertions.assertThat(
86-
testExecution.uniformPath
87-
).isEqualTo("MyClass/impactedTestCase()")
84+
Assertions.assertThat(testExecution.uniformPath).isEqualTo("MyClass/impactedTestCase()")
8885
}
8986
Assertions.assertThat(testExecutions).anySatisfy { testExecution: TestExecution ->
90-
Assertions.assertThat(
91-
testExecution.uniformPath
92-
).isEqualTo("MyClass/regularSkippedTestCase()")
87+
Assertions.assertThat(testExecution.uniformPath).isEqualTo("MyClass/regularSkippedTestCase()")
9388
}
9489
}
9590

@@ -104,29 +99,29 @@ internal class TestwiseCoverageCollectingExecutionListenerTest {
10499
val testClass = SimpleTestDescriptor.testContainer(testClassId, testCase1, testCase2)
105100
val testRoot = SimpleTestDescriptor.testContainer(rootId, testClass)
106101

107-
Mockito.`when`(resolver.getUniformPath(testCase1))
102+
whenever(resolver.getUniformPath(testCase1))
108103
.thenReturn(Optional.of("MyClass/testCase1()"))
109-
Mockito.`when`(resolver.getClusterId(testCase1))
104+
whenever(resolver.getClusterId(testCase1))
110105
.thenReturn(Optional.of("MyClass"))
111-
Mockito.`when`(resolver.getUniformPath(testCase2))
106+
whenever(resolver.getUniformPath(testCase2))
112107
.thenReturn(Optional.of("MyClass/testCase2()"))
113-
Mockito.`when`(resolver.getClusterId(testCase2))
108+
whenever(resolver.getClusterId(testCase2))
114109
.thenReturn(Optional.of("MyClass"))
115110

116111
// Start engine and class.
117112
executionListener.executionStarted(testRoot)
118-
Mockito.verify(executionListenerMock).executionStarted(testRoot)
113+
verify(executionListenerMock).executionStarted(testRoot)
119114

120115
executionListener.executionSkipped(testClass, "Test class is disabled.")
121-
Mockito.verify(executionListenerMock).executionStarted(testClass)
122-
Mockito.verify(executionListenerMock).executionSkipped(testCase1, "Test class is disabled.")
123-
Mockito.verify(executionListenerMock).executionSkipped(testCase2, "Test class is disabled.")
124-
Mockito.verify(executionListenerMock).executionFinished(testClass, TestExecutionResult.successful())
116+
verify(executionListenerMock).executionStarted(testClass)
117+
verify(executionListenerMock).executionSkipped(testCase1, "Test class is disabled.")
118+
verify(executionListenerMock).executionSkipped(testCase2, "Test class is disabled.")
119+
verify(executionListenerMock).executionFinished(testClass, TestExecutionResult.successful())
125120

126121
executionListener.executionFinished(testRoot, TestExecutionResult.successful())
127-
Mockito.verify(executionListenerMock).executionFinished(testRoot, TestExecutionResult.successful())
122+
verify(executionListenerMock).executionFinished(testRoot, TestExecutionResult.successful())
128123

129-
Mockito.verifyNoMoreInteractions(executionListenerMock)
124+
verifyNoMoreInteractions(executionListenerMock)
130125

131126
val testExecutions = executionListener.testExecutions
132127

0 commit comments

Comments
 (0)