0

I'd like to see the commands invoked by cargo test such that I can debug a failing test. With exact command I can use a debugger to find the issue more easily. Debugging is a reason why finding the command that was used to run the test is useful. There are other reasons why finding the invocation is useful.

A. K.
  • 34,395
  • 15
  • 52
  • 89
  • What commands beyond `cargo test` would you like to see, for example? Isn't it already showing which test case fails so that you know where you should start debugging? – mkrieger1 Feb 21 '23 at 18:44
  • i know which test is failing but how would i run that specific binary in a debugger? where do i find the test binary and the command that was used to run it? – A. K. Feb 21 '23 at 18:50
  • Does this answer your question? [How do I debug a failing cargo test in GDB?](https://stackoverflow.com/questions/27269315/how-do-i-debug-a-failing-cargo-test-in-gdb) – mkrieger1 Feb 21 '23 at 18:51
  • That post is helpful with debugging. However, debugging is one reason why finding the command that was used to run the test is useful. there are other reasons why finding the invocation is useful. – A. K. Feb 21 '23 at 18:57

1 Answers1

3

When you run cargo test, it will produce output similar to:

   Compiling playground v0.0.1 (/playground)
    Finished test [unoptimized + debuginfo] target(s) in 1.98s
     Running unittests src/lib.rs (target/debug/deps/playground-e4c71785a2b6bf17)

In this example, target/debug/deps/playground-e4c71785a2b6bf17 is the path to the test binary. That's all you need to run the test binary directly or under a debugger; there are no additional arguments, unless you explicitly passed some to cargo test.

Kevin Reid
  • 37,492
  • 13
  • 80
  • 108