我使用“go test -v”运行一堆单元测试。我想用delve调试它们。当我尝试运行调试器时,我得到一个“无法调试非主包”错误。那么,如何使用delve调试器来调试单元测试?使用delve调试测试
2
A
回答
1
我不熟悉的钻研,但如果它可以在编译的二进制工作,用-c
标志只是编译测试:
-c
Compile the test binary to pkg.test but do not run it
(where pkg is the last element of the package's import path).
The file name can be changed with the -o flag.
然后运行钻研的输出。
2
只需使用dlv test
:
$ dlv test -- -test.v
Type 'help' for list of commands.
(dlv) continue
=== RUN TestReadFileError
--- PASS: TestReadFileError (0.00s)
=== RUN TestReadFile
--- PASS: TestReadFile (0.00s)
[..]
PASS
Process 8014 has exited with status 0
(dlv) quit
Process 8014 has exited with status 0
您也可以通过-test.run
选择要运行的测试(就像go test -run
)。
在内部,这与Flimzy的答案(它用go test -c
编译测试二进制文件)相同,但更加简化并且不会留下.test文件供您清理。
相关问题
- 1. 使用Delve调试GO VSCode
- 2. 如何在Visual Studio中使用Delve调试器代码
- 3. 调试单元测试上使用Eclipse
- 4. ReSharper中的“使用调试器测试”?
- 5. 如何使用新测试包调试浏览器测试
- 6. 无法使用Resharper调试测试 - 无法启动调试器
- 7. Box2D调试测试
- 8. 如何使用phpunit测试用例测试ajax调用?
- 9. 使用Mocha测试javascript - 我如何使用console.log来调试测试?
- 10. 测试调用Intent.ACTION_SEND
- 11. Golang delve,你如何启动调试器并让你正在调试的应用程序启动?
- 12. 测试和调试驱动
- 13. 调试测试代码
- 14. angular-cli测试调试
- 15. 调试单元测试
- 16. 回文测试:调试
- 17. 如何调试Jest测试?
- 18. NUnit调试单个测试
- 19. 调试UWP单元测试
- 20. 如何调试(测试)GcmNetworkManager?
- 21. 使用测试
- 22. GTEST,未定义的引用“测试::测试::〜测试()”,测试::测试::测试()
- 23. 在Android Studio中调试测试用例
- 24. 用netbeans 6.9.1调试maven测试?
- 25. 在java中调试测试用例
- 26. 负载测试调试不起作用
- 27. 用node-inspector调试karma-jasmine测试
- 28. 如何用Resharper调试Jasmine测试?
- 29. 用jasmine测试ajax调用
- 30. 如何使用jasmine测试jquery调用?