-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #53410 - djrenren:custom-test-frameworks, r=alexcrichton
Introduce Custom Test Frameworks Introduces `#[test_case]` and `#[test_runner]` and re-implements `#[test]` and `#[bench]` in terms of them. Details found here: https://blog.jrenner.net/rust/testing/2018/08/06/custom-test-framework-prop.html
- Loading branch information
Showing
42 changed files
with
980 additions
and
627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/doc/unstable-book/src/language-features/custom-test-frameworks.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# `custom_test_frameworks` | ||
|
||
The tracking issue for this feature is: [#50297] | ||
|
||
[#50297]: https://github.com/rust-lang/rust/issues/50297 | ||
|
||
------------------------ | ||
|
||
The `custom_test_frameworks` feature allows the use of `#[test_case]` and `#![test_runner]`. | ||
Any function, const, or static can be annotated with `#[test_case]` causing it to be aggregated (like `#[test]`) | ||
and be passed to the test runner determined by the `#![test_runner]` crate attribute. | ||
|
||
```rust | ||
#![feature(custom_test_frameworks)] | ||
#![test_runner(my_runner)] | ||
|
||
fn my_runner(tests: &[&i32]) { | ||
for t in tests { | ||
if **t == 0 { | ||
println!("PASSED"); | ||
} else { | ||
println!("FAILED"); | ||
} | ||
} | ||
} | ||
|
||
#[test_case] | ||
const WILL_PASS: i32 = 0; | ||
|
||
#[test_case] | ||
const WILL_FAIL: i32 = 4; | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.