You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+107-7Lines changed: 107 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -216,13 +216,6 @@ module DEBUGGER__
216
216
end
217
217
```
218
218
219
-
### Tests for DAP
220
-
221
-
If you want to write tests for DAP, you should use the test generator.
222
-
After running `$ bin/gentest target.rb --open=vscode` in the terminal, VSCode will be executed.
223
-
If you need to modify existing tests, it is basically a good idea to regenerate them by the test generator instead of rewriting them directly.
224
-
Please refer to [the Microsoft "Debug Adapter Protocol" article](https://microsoft.github.io/debug-adapter-protocol/specification) to learn more about DAP formats.
225
-
226
219
#### gentest options
227
220
228
221
You can get more information about `gentest` here.
@@ -256,6 +249,113 @@ Passes if `text` is not included in the last debugger log.
256
249
257
250
Passes if `text` is included in the debuggee log.
258
251
252
+
### Tests for DAP
253
+
254
+
Currently, there are 2 kinds of test frameworks for DAP.
255
+
256
+
1. Protocol-based tests
257
+
258
+
If you want to write protocol-based tests, you should use the test generator.
259
+
After running `$ bin/gentest target.rb --open=vscode` in the terminal, VSCode will be executed.
260
+
If you need to modify existing tests, it is basically a good idea to regenerate them by the test generator instead of rewriting them directly.
261
+
Please refer to [the Microsoft "Debug Adapter Protocol" article](https://microsoft.github.io/debug-adapter-protocol/specification) to learn more about DAP formats.
262
+
263
+
2. High-level tests
264
+
265
+
High-level tests are designed to test both DAP and CDP for a single method. (Currently, only DAP is supported.)
266
+
You can write tests as follows:
267
+
268
+
```ruby
269
+
require_relative'../support/test_case'
270
+
moduleDEBUGGER__
271
+
classBreakTest < TestCase
272
+
# PROGRAM is the target script.
273
+
PROGRAM=<<~RUBY
274
+
1|moduleFoo
275
+
2|classBar
276
+
3|defself.a
277
+
4|"hello"
278
+
5|end
279
+
6|end
280
+
7|Bar.a
281
+
8| bar =Bar.new
282
+
9|end
283
+
RUBY
284
+
285
+
deftest_break1
286
+
run_protocol_scenario PROGRAMdo# Start debugger
287
+
req_add_breakpoint 5# Set a breakpoint on line 5.
288
+
req_add_breakpoint 8# Set a breakpoint on line 8.
289
+
req_continue # Resume the program.
290
+
assert_line_num 5# Check if debugger stops at line 5.
291
+
req_continue # Resume the program.
292
+
assert_line_num 8# Check if debugger stops at line 8.
0 commit comments