├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md └── workflows │ └── ci.yml ├── .gitignore ├── CONTRIBUTING.md ├── Cargo.toml ├── LICENSE ├── README.md ├── ntest ├── Cargo.toml ├── LICENSE ├── README.md ├── src │ ├── lib.rs │ └── traits.rs └── tests │ └── integration.rs ├── ntest_test_cases ├── Cargo.toml ├── LICENSE ├── README.md ├── src │ ├── lib.rs │ └── syn_helper.rs └── tests │ └── test_cases.rs └── ntest_timeout ├── Cargo.toml ├── LICENSE ├── README.md ├── src └── lib.rs └── tests └── timeout.rs /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/.github/ISSUE_TEMPLATE/bug_report.md -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/.github/ISSUE_TEMPLATE/custom.md -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/.github/ISSUE_TEMPLATE/feature_request.md -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/.github/workflows/ci.yml -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/.gitignore -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/CONTRIBUTING.md -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/Cargo.toml -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/LICENSE -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/README.md -------------------------------------------------------------------------------- /ntest/Cargo.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/ntest/Cargo.toml -------------------------------------------------------------------------------- /ntest/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /ntest/README.md: -------------------------------------------------------------------------------- 1 | # NTest 2 | 3 | [![docs](https://docs.rs/ntest/badge.svg)](https://docs.rs/ntest) 4 | [![crates](https://img.shields.io/badge/crates.io-ntest-orange)](https://crates.io/crates/ntest) 5 | [![downloads](https://badgen.net/crates/d/ntest)](https://crates.io/crates/ntest) 6 | [![build status](https://github.com/becheran/ntest/actions/workflows/ci.yml/badge.svg)](https://github.com/becheran/ntest/actions/workflows/ci.yml) 7 | [![license](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 8 | 9 | Testing framework for rust which enhances the built-in library with some useful features. Inspired by the *.Net* unit-testing framework [NUnit](https://github.com/nunit/nunit). 10 | 11 | ## Getting Started 12 | 13 | Some functions of *NTest* use [procedural macros](https://doc.rust-lang.org/reference/procedural-macros.html) which are stable for rust edition 2018. 14 | If you use the library make sure that you are using the *2018 version* of rust. Update the *Cargo.toml* file: 15 | 16 | ```toml 17 | [package] 18 | edition = "2018" 19 | # .. 20 | ``` 21 | 22 | Add the *NTest library* to your developer dependencies in the *Cargo.toml* file: 23 | 24 | ```toml 25 | [dev-dependencies] 26 | ntest = "*" 27 | ``` 28 | 29 | ## Content 30 | 31 | - `#[timeout()]` Attribute used for timeouts in tests. 32 | - `#[test_case()]` Attribute used to define multiple test cases for a test function. 33 | - `assert_about_equal!()` Compare two floating point values or vectors for equality. 34 | - `assert_false!()` Expects false argument for test case. 35 | - `assert_true!()` Expects true argument for test case. 36 | - `assert_panics!()` Expects block to panic. Otherwise the test fails. 37 | 38 | For more information read the [documentation](https://docs.rs/ntest/). 39 | 40 | ## Examples 41 | 42 | ### Create test cases 43 | 44 | ```rust 45 | use ntest::test_case; 46 | 47 | #[test_case("https://doc.rust-lang.org.html")] 48 | #[test_case("http://www.website.php", name="important_test")] 49 | fn test_http_link_types(link: &str) { 50 | test_link(link, &LinkType::HTTP); 51 | } 52 | ``` 53 | 54 | ### Timeout for long running functions 55 | 56 | ```rust 57 | use ntest::timeout; 58 | 59 | #[test] 60 | #[timeout(10)] 61 | #[should_panic] 62 | fn timeout() { 63 | loop {}; 64 | } 65 | ``` 66 | 67 | ### Combine attributes 68 | 69 | ```rust 70 | use std::{thread, time}; 71 | use ntest::timeout; 72 | use ntest::test_case; 73 | 74 | #[test_case(200)] 75 | #[timeout(100)] 76 | #[should_panic] 77 | #[test_case(10)] 78 | #[timeout(100)] 79 | fn test_function(i : u32) { 80 | let sleep_time = time::Duration::from_millis(i); 81 | thread::sleep(sleep_time); 82 | } 83 | ``` 84 | -------------------------------------------------------------------------------- /ntest/src/lib.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/ntest/src/lib.rs -------------------------------------------------------------------------------- /ntest/src/traits.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/ntest/src/traits.rs -------------------------------------------------------------------------------- /ntest/tests/integration.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/ntest/tests/integration.rs -------------------------------------------------------------------------------- /ntest_test_cases/Cargo.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/ntest_test_cases/Cargo.toml -------------------------------------------------------------------------------- /ntest_test_cases/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /ntest_test_cases/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/ntest_test_cases/README.md -------------------------------------------------------------------------------- /ntest_test_cases/src/lib.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/ntest_test_cases/src/lib.rs -------------------------------------------------------------------------------- /ntest_test_cases/src/syn_helper.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/ntest_test_cases/src/syn_helper.rs -------------------------------------------------------------------------------- /ntest_test_cases/tests/test_cases.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/ntest_test_cases/tests/test_cases.rs -------------------------------------------------------------------------------- /ntest_timeout/Cargo.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/ntest_timeout/Cargo.toml -------------------------------------------------------------------------------- /ntest_timeout/LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/ntest_timeout/LICENSE -------------------------------------------------------------------------------- /ntest_timeout/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/ntest_timeout/README.md -------------------------------------------------------------------------------- /ntest_timeout/src/lib.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/ntest_timeout/src/lib.rs -------------------------------------------------------------------------------- /ntest_timeout/tests/timeout.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/becheran/ntest/HEAD/ntest_timeout/tests/timeout.rs --------------------------------------------------------------------------------