Tokio in Integration Testing Compile Error

I wrote some unit tests for some of my sqlx code that's async. These tests together in the same file with the source code that they testing but I'd like to move them out to integration testing.

My test is annotated with the tokio runtime like this.

#[tokio::test]
async fn test_insert_find_update_delete_flow() -> sqlx::Result<()> { 
  // top secret code here
}

but now in the integration testing I'm getting the error

error[E0433]: failed to resolve: could not find `prelude` in `core`
  --> tests/it/repo/sqlx_repo/material_repo_test.rs:30:1
   |
30 | #[tokio::test]
   | ^^^^^^^^^^^^^^ could not find `prelude` in `core`
   |
   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

Does any one know why this happens?

The Tokio macros will sometimes make it seem like errors are caused by the macro even if they aren't. Try removing the macro temporarily and seeing if that changes where the error happens.

Thanks for your help! I found the problem. My lib in the project was named core. It appears this conflicts with something built into rust. I renamed my library to something else and everything is working now. Rust analyzer was also giving me random squiggles and those have gone away as well.

So for anyone that comes across this problem don't name the lib in your project core.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.