Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Fixture-based test framework for Rust
| Date | Stars |
|---|---|
| 2026-07-30 | 1575 |
| 2026-08-07 | 1576 |
| 2026-08-15 | 1578 |
| 2026-08-21 | 1576 |
| 2026-08-26 | 1576 |
| 2026-08-31 | 1577 |
| 2026-09-02 | 1578 |
| 2026-09-04 | 1579 |
| 2026-09-07 | 1580 |
| 2026-09-09 | 1579 |
| 2026-09-10 | 1580 |
| 2026-09-11 | 1583 |
| 2026-09-14 | 1584 |
| 2026-09-18 | 1587 |
| 2026-09-20 | 1586 |
| 2026-09-24 | 1587 |
| 2026-09-25 | 1588 |
| 2026-10-01 | 1588 |
| 2026-10-03 | 1589 |
| 2026-10-04 | 1588 |
| 2026-10-06 | 1588 |
| 2026-10-07 | 1589 |
| 2026-10-08 | 1590 |
| 2026-10-14 | 1591 |
| 2026-10-15 | 1592 |
| 2026-10-16 | 1592 |
| 2026-10-17 | 1593 |
| 2026-10-19 | 1593 |
| 2026-10-26 | 1594 |
| 2026-10-28 | 1596 |
| 2026-10-31 | 1597 |
| 2026-11-02 | 1598 |
| 2026-11-03 | 1598 |
| 2026-11-04 | 1598 |
Today
— stars today
This week
+2 stars this week
This month
+10 stars this month
Momentum
37.0
growth rate 0.13%/day
[![Crate][crate-image]][crate-link]
[![Docs][docs-image]][docs-link]
[![Status][test-action-image]][test-action-link]
[![Apache 2.0 Licensed][license-apache-image]][license-apache-link]
[![MIT Licensed][license-mit-image]][license-mit-link]
# Fixture-based test framework for Rust
## Introduction
`rstest` uses procedural macros to help you on writing
fixtures and table-based tests. To use it, add the
following lines to your `Cargo.toml` file:
```toml
[dev-dependencies]
rstest = "0.28.0"
```
### Features
- `async-timeout`: `timeout` for `async` tests (Default enabled)
- `crate-name`: Import `rstest` package with different name (Default enabled)
### Fixture
The core idea is that you can inject your test dependencies
by passing them as test arguments. In the following example,
a `fixture` is defined and then used in two tests,
simply providing it as an argument:
```rust
use rstest::*;
#[fixture]
pub fn fixture() -> u32 { 42 }
#[rstest]
fn should_success(fixture: u32) {
assert_eq!(fixture, 42);
}
#[rstest]
fn should_fail(fixture: u32) {
assert_ne!(fixture, 42);
}
```
### Parametrize
You can also inject values in some other ways. For instance, you can
create a set of tests by simply providing the injected values for each
case: `rstest` will generate an independent test for each case.
```rust
use rstest::rstest;
#[rstest]
#[case(0, 0)]
#[case(1, 1)]
#[case(2, 1)]
#[case(3, 2)]
#[case(4, 3)]
fn fibonacci_test(#[case] input: u32, #[case] expected: u32) {
assert_eq!(expected, fibonacci(input))
}
```
Running `cargo test` in this case executes five tests:
```bash
running 5 tests
test fibonacci_test::case_1 ... ok
test fibonacci_test::case_2 ... ok
test fibonacci_test::case_3 ... ok
test fibonacci_test::case_4 ... ok
test fibonacci_test::case_5 ... ok
test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
```
If you need to just providing a bunch of values for which you
need to run your test, you can use `#[values(list, of, values)]`
argument attribute:
```rust
use rstest::rstest;
#[rstest]
fn should_be_invalid(
#[values(None, Some(""), Some(" "))]
value: Option<&str>
) {
assert!(!valid(value))
}
```
Or create a _matrix_ test by using _list of values_ for some
variables that will generate the cartesian product of all the
values.
#### Omit case values
A `#[case]` argument can declare the value to use when a case omits it:
`#[case(default)]` uses `Default::default()`, `#[case(default(expr))]` uses
`expr` and `#[case(opt)]` (for `Option<T>` arguments) wraps the given plain
`T` value in `Some()` and uses `None` when it's omitted. You can omit the
trailing values or use `_` to skip a value in the middle, while omitting the
value of a plain `#[case]` argument is still a compile error.
```rust
use rstest::rstest;
#[rstest]
#[case(" hello ")]
#[case("--hello--", _, '-')]
#[case("**bye**", "bye", '*')]
fn trim(
#[case] input: &str,
#[case(default("hello"))] expected: &str,
#[case(opt)] c: Option<char>,
) {
let trimmed = match c {
Some(c) => input.trim_matches(c),
None => input.trim(),
};
assert_eq!(expected, trimmed)
}
```
#### Use Parametrize definition in more tests
If you need to use a test list for more than one test you can use [`rstest_reuse`][reuse-crate-link]
crate. With this helper crate you can define a template and use it everywhere.
```rust
use rstest::rstest;
use rstest_reuse::{self, *};
#[template]
#[rstest]
#[case(2, 2)]
#[case(4/2, 2)]
fn two_simple_cases(#[case] a: u32, #[case] b: u32) {}
#[apply(two_simple_cases)]
fn it_works(#[case] a: u32, #[case] b: u32) {
assert!(a == b);
}
```
See [`rstest_reuse`][reuse-crate-link] for more details.
#### Feature flagged cases
In case you want certain test cases to only be present if a certain feature is
enabled, use `#[cfg_attr(feature = …, case(…))]`:
```rust
use rstest::rstest;
#[rstest]
#[case(2, 2)]
#[cfg_attr(feature = "frac", case(4/2, 2))]
fn it_works(#[caseExcerpt of 18,820 characters
Read on GitHub699
@actions
31
13
7
6
6
5
5
5
4
2
Amando · @RustQuant · Australia
2
2
2
1
1
1
1
Orhun Parmaksız · @ratatui | @jetbrains | @archlinux · Germany
1
Oliver Borchert · @Quantco · Germany
1
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:0d9658cc251a955e, topic:testing