I try to run integration test but when I run cargo run it shows that it has run 0 test.
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
this is my integration test:
use listing_people_api_actix;
use actix_web::{HttpRequest, HttpResponse, test::TestServer};
use enpoints::people::messages::{SendMessage};
#[test]
fn get_person() {
let mut srv = TestServer::new(|app| app.handler(SendMessage::send_get_person));
let request = srv.get().finish().unwrap();
let response = srv.execute(request.send()).unwrap();
assert!(response.status().is_success());
}
Now the test run, I had to put the tests folder in the root directory, The another issue that I have is that I try to import project to test but I have this error when I run the test:
error[E0432]: unresolved import `listing_people_api_actix`
--> tests/people_test.rs:2:5
|
2 | use listing_people_api_actix::enpoints;
| ^^^^^^^^^^^^^^^^^^^^^^^^ maybe a missing `extern crate listing_people_api_actix;`?
and also doesn't work if I import with extern crate listing_people_api_actix;
The tests directory is for integration tests, and these exist outside of your crate. You need to import your crate and access these modules in the same way that an external user of your library would:
extern name_of_project;
use name_of_project::listing_people_api_actix;