bitwizeshift / bitwizeshift/oxtest
Support attributes in subtests
- Dominant language
- Rust
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
The current mechanism for subtests simply acts as a series of statements defined in a `subtest! { ... }` macro. Although this functionally works, it suffers the significant drawback that it is unable to have custom attributes specified -- such as #[should_panic]` or `#[ignore]`, which are needed for testing.
It's unclear what the best direction forward for this is. A couple thoughts come to mind:
* Extend the DSL to support `[]` syntax, e.g. `subtest! { |name| [should_panic][ignore] ... }`, this is kind of gross -- but would work.
* Change the syntax entirely; perhaps using function definitions instead:
```rust
#[neotest::test]
fn test_vec_index() {
let vec: Vec = Vec::default();
#[neotest::subtest]
#[should_panic]
fn out_of_bounds_panics() {
vec[20];
}
}
```
The downside to this approach is that it's not clear that `vec` is within `fn out_of_bounds_panics()` scope, since this typically is not a true closure. The upside is that this has a clear mechanism for identifying attributes, the test ident, etc.
The exact approach is yet to be determined.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the `subtest! { ... }` macro and the surrounding test framework entry points. Compare the proposed attribute-oriented DSL and function-based syntax, including how subtest scope would work. Done requires a decided approach that supports attributes such as `#[should_panic]` and `#[ignore]` for subtests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100