@@ -4,12 +4,17 @@ import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
4
4
import com.intellij.plugin.powershell.ide.debugger.PowerShellSuspendContext
5
5
import com.intellij.plugin.powershell.testFramework.DebuggerTestBase
6
6
import com.intellij.plugin.powershell.testFramework.PowerShellTestSession
7
+ import com.intellij.plugin.powershell.testFramework.runInEdt
8
+ import com.intellij.testFramework.junit5.TestApplication
7
9
import com.intellij.xdebugger.XDebuggerTestUtil
8
10
import com.jetbrains.rd.util.lifetime.Lifetime
9
- import junit.framework.TestCase
11
+ import org.junit.jupiter.api.Assertions
12
+ import org.junit.jupiter.api.Test
10
13
11
- class StepTest : DebuggerTestBase () {
14
+ @TestApplication
15
+ class StepTest : DebuggerTestBase () {
12
16
17
+ @Test
13
18
fun testStepOver () {
14
19
runInEdt {
15
20
val psiFile = copyAndOpenFile(" debugger/stepTest.ps1" )
@@ -22,25 +27,31 @@ class StepTest: DebuggerTestBase() {
22
27
XDebuggerTestUtil .toggleBreakpoint(project, file, line)
23
28
Lifetime .using { lt ->
24
29
val debugSession = testSession.startDebugSession(lt)
25
- assertTrue(" Pause should be triggered in ${testSession.waitForBackgroundTimeout} " , XDebuggerTestUtil .waitFor(
26
- testSession.sessionListener.pausedSemaphore,
27
- testSession.waitForBackgroundTimeout.toMillis()
28
- ))
30
+
31
+ Assertions .assertTrue(
32
+ XDebuggerTestUtil .waitFor(
33
+ testSession.sessionListener.pausedSemaphore, testSession.waitForBackgroundTimeout.toMillis()
34
+ ), " Pause should be triggered in ${testSession.waitForBackgroundTimeout} "
35
+ )
36
+
29
37
val suspendContext = debugSession.suspendContext as PowerShellSuspendContext
30
- TestCase .assertEquals(line, suspendContext.activeExecutionStack.topFrame?.sourcePosition?.line)
38
+ Assertions .assertEquals(line, suspendContext.activeExecutionStack.topFrame?.sourcePosition?.line)
31
39
debugSession.stepOver(false )
32
- assertTrue(" Pause should be triggered in ${testSession.waitForBackgroundTimeout} " , XDebuggerTestUtil .waitFor(
33
- testSession.sessionListener.pausedSemaphore,
34
- testSession.waitForBackgroundTimeout.toMillis()
35
- ))
36
- TestCase .assertEquals(
40
+
41
+ Assertions .assertTrue(
42
+ XDebuggerTestUtil .waitFor(
43
+ testSession.sessionListener.pausedSemaphore, testSession.waitForBackgroundTimeout.toMillis()
44
+ ), " Pause should be triggered in ${testSession.waitForBackgroundTimeout} "
45
+ )
46
+ Assertions .assertEquals(
37
47
line + 1 ,
38
48
(debugSession.suspendContext as PowerShellSuspendContext ).activeExecutionStack.topFrame?.sourcePosition?.line
39
49
)
40
50
}
41
51
}
42
52
}
43
53
54
+ @Test
44
55
fun testStepIn () {
45
56
runInEdt {
46
57
val psiFile = copyAndOpenFile(" debugger/stepTest.ps1" )
@@ -55,25 +66,34 @@ class StepTest: DebuggerTestBase() {
55
66
XDebuggerTestUtil .toggleBreakpoint(project, file, line)
56
67
Lifetime .using { lt ->
57
68
val debugSession = testSession.startDebugSession(lt)
58
- assertTrue(" Pause should be triggered in ${testSession.waitForBackgroundTimeout} " , XDebuggerTestUtil .waitFor(
59
- testSession.sessionListener.pausedSemaphore,
60
- testSession.waitForBackgroundTimeout.toMillis()
61
- ))
62
- val suspendContext = debugSession.suspendContext as PowerShellSuspendContext
63
- TestCase .assertEquals(line, suspendContext.activeExecutionStack.topFrame?.sourcePosition?.line)
69
+
70
+ Assertions .assertTrue(
71
+ XDebuggerTestUtil .waitFor(
72
+ testSession.sessionListener.pausedSemaphore, testSession.waitForBackgroundTimeout.toMillis()
73
+ ), " Pause should be triggered in ${testSession.waitForBackgroundTimeout} "
74
+ )
75
+
76
+ Assertions .assertEquals(
77
+ line,
78
+ (debugSession.suspendContext as PowerShellSuspendContext ).activeExecutionStack.topFrame?.sourcePosition?.line
79
+ )
80
+
64
81
debugSession.stepInto()
65
- assertTrue(" Pause should be triggered in ${testSession.waitForBackgroundTimeout} " , XDebuggerTestUtil .waitFor(
66
- testSession.sessionListener.pausedSemaphore,
67
- testSession.waitForBackgroundTimeout.toMillis()
68
- ))
69
- TestCase .assertEquals(
82
+
83
+ Assertions .assertTrue(
84
+ XDebuggerTestUtil .waitFor(
85
+ testSession.sessionListener.pausedSemaphore, testSession.waitForBackgroundTimeout.toMillis()
86
+ ), " Pause should be triggered in ${testSession.waitForBackgroundTimeout} "
87
+ )
88
+ Assertions .assertEquals(
70
89
stepInLine,
71
90
(debugSession.suspendContext as PowerShellSuspendContext ).activeExecutionStack.topFrame?.sourcePosition?.line
72
91
)
73
92
}
74
93
}
75
94
}
76
95
96
+ @Test
77
97
fun testStepOut () {
78
98
runInEdt {
79
99
val psiFile = copyAndOpenFile(" debugger/stepTest.ps1" )
@@ -89,26 +109,28 @@ class StepTest: DebuggerTestBase() {
89
109
XDebuggerTestUtil .toggleBreakpoint(project, file, line)
90
110
Lifetime .using { lt ->
91
111
val debugSession = testSession.startDebugSession(lt)
92
- assertTrue(" Pause should be triggered in ${testSession.waitForBackgroundTimeout} " , XDebuggerTestUtil .waitFor(
93
- testSession.sessionListener.pausedSemaphore,
94
- testSession.waitForBackgroundTimeout.toMillis()
95
- ))
112
+ Assertions .assertTrue(
113
+ XDebuggerTestUtil .waitFor(
114
+ testSession.sessionListener.pausedSemaphore, testSession.waitForBackgroundTimeout.toMillis()
115
+ ), " Pause should be triggered in ${testSession.waitForBackgroundTimeout} "
116
+ )
96
117
val suspendContext = debugSession.suspendContext as PowerShellSuspendContext
97
- TestCase .assertEquals(line, suspendContext.activeExecutionStack.topFrame?.sourcePosition?.line)
118
+ Assertions .assertEquals(line, suspendContext.activeExecutionStack.topFrame?.sourcePosition?.line)
98
119
debugSession.stepOut()
99
- assertTrue(" Pause should be triggered in ${testSession.waitForBackgroundTimeout} " , XDebuggerTestUtil .waitFor(
100
- testSession.sessionListener.pausedSemaphore,
101
- testSession.waitForBackgroundTimeout.toMillis()
102
- ))
103
- TestCase .assertEquals(
120
+ Assertions .assertTrue(
121
+ XDebuggerTestUtil .waitFor(
122
+ testSession.sessionListener.pausedSemaphore, testSession.waitForBackgroundTimeout.toMillis()
123
+ ), " Pause should be triggered in ${testSession.waitForBackgroundTimeout} "
124
+ )
125
+ Assertions .assertEquals(
104
126
stepOutLine,
105
127
(debugSession.suspendContext as PowerShellSuspendContext ).activeExecutionStack.topFrame?.sourcePosition?.line
106
128
)
107
129
}
108
130
}
109
131
}
110
132
111
- override fun tearDownEdt () {
133
+ override fun tearDownInEdt () {
112
134
FileEditorManagerEx .getInstanceEx(project).closeAllFiles()
113
135
}
114
136
}
0 commit comments