Commit graph

12 commits

Author SHA1 Message Date
Víctor Martínez
bfe1703448
fix: mut ownership doesn't work (#60) 2025-11-06 14:18:27 +01:00
Víctor Martínez
39756352a8
feat: make it so immutable references & full ownership can be taken depending on context (#58)
This pull requests introduces changes that make the use of the `test_context` macro more flexible.

Now, if the teardown is not skipped (default behavior), either an `immutable` or a `mutable` reference can be used for the context.

If the teardown is skipped with the `skip_teardown` option, an `immutable`, a `mutable` reference or full ownership can be taken.

So now the following is possible:

```rust
#[test_context(TeardownPanicContext, skip_teardown)]
#[tokio::test]
async fn test_async_skip_teardown(_ctx: &mut TeardownPanicContext) {}

#[test_context(TeardownPanicContext, skip_teardown)]
#[tokio::test]
async fn test_async_skip_teardown_with_immutable_ref(_ctx: &TeardownPanicContext) {}

#[test_context(TeardownPanicContext, skip_teardown)]
#[tokio::test]
async fn test_async_skip_teardown_with_full_ownership(_ctx: TeardownPanicContext) {}

#[test_context(TeardownPanicContext, skip_teardown)]
#[test]
fn test_sync_skip_teardown(_ctx: &mut TeardownPanicContext) {}

#[test_context(TeardownPanicContext, skip_teardown)]
#[test]
fn test_sync_skip_teardown_with_immutable_ref(_ctx: &TeardownPanicContext) {}

#[test_context(TeardownPanicContext, skip_teardown)]
#[test]
fn test_sync_skip_teardown_with_full_ownership(_ctx: TeardownPanicContext) {}
```
2025-11-06 13:52:20 +01:00
JasterV
5e407cdfa2 chore: update CHANGELOGS 2025-11-04 17:38:55 +01:00
Víctor Martínez
ef4bdb28a9
fix: Regression in version 0.5.0 (#55)
An attempt to fix the issue defined in https://github.com/JasterV/test-context/issues/53 & some refactors
2025-11-04 17:27:53 +01:00
Vyacheslav
9227f3e693
Added the ability to work with rstest (#51)
* [FIX-CONFLICT-WITH-RSTEST-V2]: semi-stable version, fix test_context function, remove unnecessary field, remove wrapper function, add  ability to work with rstest and same

* [FIX-CONFLICT-WITH-RSTEST-V2]: stable version, fix bugs with AssertUnwindSafe in sync_wrapper_body, remove redundant code, fix two tests, add notes for this tests

* [FIX-CONFLICT-WITH-RSTEST-V2]: stable version, fix context name extraction function, fix readme, fix docs, increase version of crate

---------

Co-authored-by: Vyacheslav Volkov <v.volkov@st-falcon.ru>
2025-10-29 10:19:40 +01:00
Changju Lee
a58e13ecf5
feat: Support generic types in test_context macro (#44)
- Allow using test_context with generic contexts like MyContext<T>
2025-01-27 11:53:39 +01:00
Víctor Martínez
dc2992cbff
feat: add support for the skip_teardown keyword (#40)
* feat: add support for the skip_teardown keyword
2024-02-27 23:26:40 +01:00
Victor Martinez
0fed446341 refactor: clean up the macro implementation 2024-02-26 16:03:47 +01:00
Victor Martinez
be1f0e1dbd chore: upgrade to 0.2.0 version 2024-02-26 12:12:38 +01:00
Victor Martinez
cb4043fae6 refactor: remove support for async-trait crate 2024-02-26 12:05:07 +01:00
Victor Martinez
58faeefa63 chore: update workspace properties 2024-02-26 00:27:59 +01:00
Victor Martinez
3539bcdd6d refactor: restructure the workspace members organization 2024-02-26 00:19:53 +01:00