'How vscode debug test golang test case

When I unit test the code I've written, it turns out that the result is wrong. At this point, I break points in the unit test and the code under test, and then run the debug test, hoping to step through the debugging to find the error, but it directly returns the same result as the run test. I don't know where I am going wrong, my config file is as follows

    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "test",
            "program": "${fileDirname}"
        }
    ]

The debug results are as follows

Starting: /data/gopath/bin/dlv dap --check-go-version=false --listen=127.0.0.1:33340 --log-dest=3 from /data/gopath/src/gopractise-demo/sorts
DAP server listening at: 127.0.0.1:33340
Type 'dlv help' for list of commands.
--- FAIL: TestHeapSort (0.00s)
    --- FAIL: TestHeapSort/heapSort_sort1 (0.00s)
        heap_test.go:38: HeapSort() = [5 1 10 3 6 12 2 4 7 11 9 8], want [1 2 3 4 5 6 7 8 9 10 11 12]
    --- FAIL: TestHeapSort/heapSort_sort2 (0.00s)
        heap_test.go:38: HeapSort() = [3 5 8 6 1 4 2 7], want [1 2 3 4 5 6 7 8]
FAIL
Process 28790 has exited with status 1
Detaching
dlv dap (28753) exited with code: 0

It's not the single-step debugging I expected.

I did not find this error related to the debug test, looking forward to your answer, thank you enter image description here

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source