Document #[test_case] and #![test_runner]

This commit is contained in:
John Renner 2018-08-30 13:40:33 -07:00
parent 08ea5b7c78
commit e5ed105716
5 changed files with 37 additions and 4 deletions

View File

@ -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;
```

View File

@ -10,5 +10,5 @@
fn main() {
concat!(test!());
//~^ error: `test` can only be used in attributes
//~^ error: cannot find macro `test!` in this scope
}

View File

@ -1,4 +1,4 @@
error: `test` can only be used in attributes
error: cannot find macro `test!` in this scope
--> $DIR/issue-11692-2.rs:12:13
|
LL | concat!(test!());

View File

@ -11,4 +11,4 @@
#[macro_export]
macro_rules! test {
() => {};
}
}

View File

@ -15,4 +15,4 @@
#[macro_use] extern crate test_macro;
#[test]
fn foo(){}
fn foo(){}