I've been testing my ink! contract and one of the tests failed.
The test that failed:
#[ink::test]
fn get_bids_made_works() {
let bid = 100u128;
let mut bag = Moneybag::new(bid);
let accounts = default_accounts::<DefaultEnvironment>();
let bob: AccountId = accounts.bob;
set_caller::<DefaultEnvironment>(bob);
bag.add_bid(bid).unwrap();
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.:
#[ink::test]
#[ink::test_name("NiceTest")]
.
.
.
How do I distinguish one failed test from another?
cargo +nightly test
instead ofcargo +nightly contract test
and post the output here? The latter doesn't provide very helpful output (see github.com/paritytech/cargo-contract/issues/421).cargo +nightly contract test
just because of this line. But your advise solved the problem.