To debug tests, with dape, specify :mode "test". For go specifically, you also need to specify the package or use this utility function from the wiki:
(add-to-list 'dape-configs
`(dlv
modes (go-mode go-ts-mode)
ensure dape-ensure-command
fn (dape-config-autoport dape-config-tramp)
command "dlv"
command-insert-stderr t
command-args ("dap" "--listen" "127.0.0.1::autoport")
command-cwd (lambda()(if (string-suffix-p "_test.go" (buffer-name))
default-directory (dape-cwd)))
port :autoport
:type "debug"
:request "launch"
:mode (lambda() (if (string-suffix-p "_test.go" (buffer-name)) "test" "debug"))
:program "."
:cwd "."
:args (lambda()
(require 'which-func)
(if (string-suffix-p "_test.go" (buffer-name))
(when-let* ((test-name (which-function))
(test-regexp (concat "^" test-name "$")))
(if test-name `["-test.run" ,test-regexp]
(error "No test selected")))
[]))))