I have following code in decl_module
#[weight = 10_000 + T::DbWeight::get().reads_writes(1,1)]
pub fn create_deparment(origin, name: Vec<u8>, location: Vec<u8>, detail: Vec<u8>) -> dispatch::DispatchResult {
let _who = ensure_signed(origin)?;
let oldcount = DeparmentCount::get();
debug::info!("Old Deparment Count: {:?}", oldcount);
// print("Old Deparment Count");
Ok(())
}
This is my test:
#[test]
fn create_deparment_test() {
new_test_ext().execute_with(|| {
let _result = TemplateModule::create_deparment(Origin::signed(1), "Education".as_bytes().to_vec(), "India".as_bytes().to_vec(), "hashcode".as_bytes().to_vec());
});
}
I want to print the debug::info in terminal while running cargo test.
cargo test -- --nocapture
Is it possible?
Edit:
println! is working if you test only using template crate, so one can remove the println! while building the substrate runtime.
To use println!
you've to make sure your test is 'std'.
Something like:
#[cfg(std)]
mod tests;
// ---
// But some tests are no std
mod tests;
If you want to use info!
try RUST_LOG=info cargo t -- --nocapture
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With