How to use a public struct defined in a source file of /src folder from a test.rs file in /tests folder?
04:32 19 Aug 2026

I'm trying to test a REST client API generated with OpenAPI generator. The src folder content is generated by OpenAPI generator, I shouldn't edit it as it can be re-generated.

├── src
│   ├── apis
│   │   ├── configuration.rs
│   │   ├── events_notification_api.rs
│   │   ├── events_subscription_api.rs
│   │   ├── mod.rs
│   │   ├── service_api.rs
│   │   └── service_instance_api.rs
│   ├── lib.rs
│   └── models
│       └──  [...]
│   ├── debug
│   │   ├── [...]
└── tests
    └── tests.rs

The lib.rs has this content:

#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]

extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;
extern crate reqwest;

pub mod apis;
pub mod models;

and the configuration.rs this one:

#[derive(Debug, Clone)]
pub struct Configuration {
    pub base_path: String,
    pub user_agent: Option,
    pub client: reqwest::Client,
    pub basic_auth: Option,
    pub oauth_access_token: Option,
    pub bearer_access_token: Option,
    pub api_key: Option,
}

pub type BasicAuth = (String, Option);

#[derive(Debug, Clone)]
pub struct ApiKey {
    pub prefix: Option,
    pub key: String,
}


impl Configuration {
    pub fn new() -> Configuration {
        Configuration::default()
    }
}

impl Default for Configuration {
    fn default() -> Self {
        Configuration {
            base_path: "https://our.host:443/context/serviceInventoryManagement/v5.0".to_owned(),
            user_agent: Some("OpenAPI-Generator/5.0.0/rust".to_owned()),
            client: reqwest::Client::new(),
            basic_auth: None,
            oauth_access_token: None,
            bearer_access_token: None,
            api_key: None,
        }
    }
}

Instead of adding tests to lib.rs that can be overwritten, I've chosen to create a tests folder, where I've put a test.rs file, I can run with a cargo test as soon as I've started the REST server part, aside.

But I'm failing to access my Configuration structure to create an instance of it.

mod test {
    use configuration::Configuration;

    /**  */
    #[test]
    fn dummy() {
       // list_service(configuration: &configuration::Configuration, filter: Option>, default_filter: Option, all_providers: Option)
    }

   /** Returns a generic configuration to join the default REST server */
   fn genericConfiguration() {
       let mut cfg = Configuration::new;
   }
}

I'm receiving a compilation error at cargo test:

tests/tests.rs:2:9
  |
2 |     use configuration::Configuration;
  |         ^^^^^^^^^^^^^ use of unresolved module or unlinked crate `configuration`

How to declare my use directive correctly?

testing rust