[−][src]Attribute Macro ntest_timeout::timeout
#[timeout]
The timeout attribute can be used for tests to timeout after a given time.
With the #[timeout] attribute a timeout in milliseconds is added to a test.
The function input must be of type int. For example #[timeout(10)] will timeout after 10 milliseconds.
Examples
This example will not panic
ⓘThis example is not tested
#[test] #[timeout(100)] fn no_timeout() { let fifty_millis = time::Duration::from_millis(50); thread::sleep(fifty_millis); }
This example will panic. The function panics after 10 milliseconds
ⓘThis example is not tested
#[test] #[timeout(10)] #[should_panic] fn timeout() { let fifty_millis = time::Duration::from_millis(50); thread::sleep(fifty_millis); }