I've been testing my ink! contract and one of the tests failed.
The test that failed:

fn get_bids_made_works() {
    let bid = 100u128;
    let mut bag = Moneybag::new(bid);
    let accounts = default_accounts::<DefaultEnvironment>();
    let bob: AccountId = accounts.bob;
    assert_eq!(bag.get_bids_made(), 3);       

The Error message:

 Finished test [unoptimized + debuginfo] target(s) in 2.76s
     Running unittests src/lib.rs (target/debug/deps/moneybag-1ffd8ca9ab27f17f)
error: test failed, to rerun pass '--lib'
ERROR: `"/home/creestl/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo" "test" ""` failed with exit code: Some(101)

From the error message it is not clear which test function that was. But to me it was just obvious that it was the get_bids_made_works that I've provided above. But what if it was not so obvious? And what if instead of 6 tests I had 50?
I see that in the error message there is a "test" "" part. And I suppose that it should include the name of the test function, but it does not. Should I use some macro to define test's name? e.g.:


How do I distinguish one failed test from another?

  • Please add more details and a snippet of this test. how to ask a good question is something to review too ;) As is, this isn't a good question
    – Nuke
    Jun 11, 2022 at 17:52
  • I've added some code and details. Pls, take a look.
    Jun 11, 2022 at 20:00
  • Can you try using cargo +nightly test instead of cargo +nightly contract test and post the output here? The latter doesn't provide very helpful output (see github.com/paritytech/cargo-contract/issues/421).
    – HCastano
    Jun 13, 2022 at 19:03
  • Oh wow, it really gives a much more detailed output. I was using cargo +nightly contract test just because of this line. But your advise solved the problem.
    Jun 14, 2022 at 14:19

1 Answer 1


Use cargo +nightly test instead of cargo +nightly contract test

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.