[FIX-CONFLICT-WITH-RSTEST-V2]: fix readme file

This commit is contained in:
Vyacheslav Volkov 2025-10-26 14:33:54 +03:00
parent f853aac180
commit 57bb18bad2
2 changed files with 64 additions and 1 deletions

View file

@ -149,4 +149,68 @@ fn test_without_teardown(ctx: &mut MyContext) {
}
```
## ⚠️ Ensure that the context type specified in the macro matches the test function argument type exactly
The error occurs when a context type with an absolute path is mixed with an it's alias.
For example:
```
mod database {
use test_context::TestContext;
pub struct Connection;
impl TestContext for :Connection {
fn setup() -> Self {Connection}
fn teardown(self) {...}
}
}
```
✅The following code will work:
```
use database::Connection as DbConn;
#[test_context(DbConn)]
#[test]
fn test1(ctx: &mut DbConn) {
//some test logic
}
// or
use database::Connection
#[test_context(database::Connection)]
#[test]
fn test1(ctx: &mut database::Connection) {
//some test logic
}
```
❌The following code will not work:
```
use database::Connection as DbConn;
#[test_context(database::Connection)]
#[test]
fn test1(ctx: &mut DbConn) {
//some test logic
}
// or
use database::Connection as DbConn;
#[test_context(DbConn)]
#[test]
fn test1(ctx: &mut database::Connection) {
//some test logic
}
```
Type mismatches will cause context parsing to fail during either static analysis or compilation.
License: MIT

View file

@ -132,7 +132,6 @@ fn handle_result(result_name: Ident) -> proc_macro2::TokenStream {
}
}
// TODO: Possible bugs when using: type aliases, full and relative paths, generic types in context type
fn extract_and_remove_context_arg(
mut input: syn::ItemFn,
expected_context_type: syn::Type,