Skip to content

Commit

Permalink
Merge pull request #265 from memark/patch-1
Browse files Browse the repository at this point in the history
Minor doc improvements
  • Loading branch information
la10736 authored Jul 8, 2024
2 parents 856de33 + cfff419 commit fb4fa50
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions rstest_reuse/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This crate gives a way to define tests set and apply them to every case you need
test. With `rstest` crate you can define a tests list but if you want to apply the same tests
to another test function you must rewrite all cases or write some macros that do the job.

Both solutions have some drawbreak:
Both solutions have some drawbacks:

- introduce duplication
- macros makes code harder to read and shift out the focus from tests core
Expand All @@ -24,7 +24,8 @@ Here is a simple example:
```rust
use rstest::rstest;
use rstest_reuse::{self, *};
// Here we define the template. This define

// Here we define the template. This defines
// * The test list name to `two_simple_cases`
// * cases: here two cases
#[template]
Expand All @@ -33,7 +34,9 @@ use rstest_reuse::{self, *};
#[case(4/2, 2)]
// Define a and b as cases arguments
fn two_simple_cases(#[case] a: u32, #[case] b: u32) {}
// Here we apply the `two_simple_cases` template: That is expanded in

// Here we apply the `two_simple_cases` template.
// This is expanded into:
// #[template]
// #[rstest]
// #[case(2, 2)]
Expand All @@ -45,8 +48,9 @@ fn two_simple_cases(#[case] a: u32, #[case] b: u32) {}
fn it_works(a: u32, b: u32) {
assert!(a == b);
}

// Here we reuse the `two_simple_cases` template to create two
// other tests
// other tests:
#[apply(two_simple_cases)]
fn it_fail(a: u32, b: u32) {
assert!(a != b);
Expand Down

0 comments on commit fb4fa50

Please sign in to comment.