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-24 | 1575 |
| 2026-07-25 | 1575 |
| 2026-07-28 | 1575 |
| 2026-07-30 | 1575 |
| 2026-08-06 | 1575 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/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.26.1"
```
### 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.
#### 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(#[case] a: u32, #[case] b: u32) {
assert!(a == b);
}
```
This also works with [`rstest_reuse`][reuse-crate-link].
### Magic Conversion
If you need a value where its type implement `FromStr()` trait you can use a literal
string to build it:
```rust
# use rstest::rstest;
# use std::net::SocketAddr;
#[rstest]
#[case("1.2.3.4:8080", 8080)]
#[case("127.0.0.1:9000", 9000)]
fn check_port(#[case] addr: SocketAddr, #[case] expected: u16) {
assert_eq!(expected, addr.port());
}
```
You can use this feature also in value list and in fixture default value.
### Async
`rstest` supports async tests, but makes no assumptions about what
async runtime you are using. Async tests require either an
[explicit test attribute](#explicit-test-attribute) or an
[implicit test attribute](#implicit-test-attribute).
You are responsible for providing any apExcerpt of 17,973 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:30a6c04d525ba024, topic:testing