Skip to content

Is it possible to have more detailed error messages when a mock fails? #109

Description

@ffguven

Hi,

When an injector fails within my unit tests, I receive:

thread 'linux_util::namespace::mount::tests::mount_happy' panicked at src/linux_util/namespace/mount.rs:228:27:
Fake function called with unexpected arguments
stack backtrace:
   0: __rustc::rust_begin_unwind
             at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/std/src/panicking.rs:697:5
   1: core::panicking::panic_fmt
             at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/panicking.rs:75:14
   2: nucleus::linux_util::namespace::mount::tests::mount_happy::fake
             at /home/fatih/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/injectorpp-0.4.0/src/interface/macros.rs:326:18
   3: nucleus::linux_util::namespace::mount::mount
             at ./src/linux_util/namespace/mount.rs:76:9
   4: nucleus::linux_util::namespace::mount::tests::mount_happy
             at ./src/linux_util/namespace/mount.rs:238:22
   5: nucleus::linux_util::namespace::mount::tests::mount_happy::{{closure}}
             at ./src/linux_util/namespace/mount.rs:167:21
   6: core::ops::function::FnOnce::call_once
             at /home/fatih/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:253:5
   7: core::ops::function::FnOnce::call_once
             at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/ops/function.rs:253:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
test linux_util::namespace::mount::tests::mount_happy ... FAILED

failures:

without any reasoning how the arguments does not match with the expected arguments by InjectorPP. I tried to execute this with RUST_BACKTRACE=full as well, but it just provides some more steps in the stacktrace, not the actual reason of why the injector failed.

Is there a way to make the error message explicit that where exactly the fake function fails to capture the actual request?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions