NTest

docs crates downloads build status license

Testing framework for rust which enhances the built-in library with some useful features. Inspired by the .Net unit-testing framework NUnit.

Getting Started

Some functions of NTest use procedural macros which are stable for rust edition 2018. If you use the library make sure that you are using the 2018 version of rust. Update the Cargo.toml file:

```toml [package] edition = "2018"

..

```

Add the NTest library to your developer dependencies in the Cargo.toml file:

toml [dev-dependencies] ntest = "*"

Content

For more information read the documentation.

Examples

Create test cases

```rust use ntest::test_case;

[test_case("https://doc.rust-lang.org.html")]

[testcase("http://www.website.php", name="importanttest")]

fn testhttplinktypes(link: &str) { testlink(link, &LinkType::HTTP); } ```

Timeout for long running functions

```rust use ntest::timeout;

[test]

[timeout(10)]

[should_panic]

fn timeout() { loop {}; } ```

Combine attributes

```rust use std::{thread, time}; use ntest::timeout; use ntest::test_case;

[test_case(200)]

[timeout(100)]

[should_panic]

[test_case(10)]

[timeout(100)]

fn testfunction(i : u32) { let sleeptime = time::Duration::frommillis(i); thread::sleep(sleeptime); } ```