@@ -6,16 +6,15 @@ import com.teamscale.test_impacted.test_descriptor.ITestDescriptorResolver
66import org.assertj.core.api.Assertions
77import org.junit.jupiter.api.Test
88import org.junit.platform.engine.EngineExecutionListener
9- import org.junit.platform.engine.TestDescriptor
109import org.junit.platform.engine.TestExecutionResult
1110import 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.*
1512import java.util.*
1613
14+ @Suppress(" INLINE_FROM_HIGHER_PLATFORM" )
1715/* * Tests for [TestwiseCoverageCollectingExecutionListener]. */
1816internal 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