MCPcopy Index your code
hub / github.com/becheran/ntest

github.com/becheran/ntest @ntest-v0.9.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release ntest-v0.9.5 ↗ · + Follow
67 symbols 79 edges 8 files 3 documented · 4% updated 6mo ago★ 755 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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:

[package]
edition = "2018"
# ..

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

[dev-dependencies]
ntest = "*"

Content

  • #[timeout()] Attribute used for timeouts in tests.
  • #[test_case()] Attribute used to define multiple test cases for a test function.
  • assert_about_equal!() Compare two floating point values or vectors for equality.
  • assert_false!() Expects false argument for test case.
  • assert_true!() Expects true argument for test case.
  • assert_panics!() Expects block to panic. Otherwise the test fails.

For more information read the documentation.

Examples

Create test cases

use ntest::test_case;

#[test_case("https://doc.rust-lang.org.html")]
#[test_case("http://www.website.php", name="important_test")]
fn test_http_link_types(link: &str) {
    test_link(link, &LinkType::HTTP);
}

Timeout for long running functions

use ntest::timeout;

#[test]
#[timeout(10)]
#[should_panic]
fn timeout() {
    loop {};
}

Combine attributes

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

#[test_case(200)]
#[timeout(100)]
#[should_panic]
#[test_case(10)]
#[timeout(100)]
fn test_function(i : u32) {
    let sleep_time = time::Duration::from_millis(i);
    thread::sleep(sleep_time);
}

Extension points exported contracts — how you extend this code

MaxDifference (Interface)
Helper trait for `assert_about_equal` macro. Returns the max difference between two vectors of floats. Can also be used [4 …
ntest/src/traits.rs

Core symbols most depended-on inside this repo

parse_test_case_attributes
called by 2
ntest_test_cases/src/lib.rs
calculate_test_name
called by 2
ntest_test_cases/src/lib.rs
number_to_identifier
called by 2
ntest_test_cases/src/syn_helper.rs
check_other_attributes
called by 1
ntest_timeout/src/lib.rs
get_timeout
called by 1
ntest_timeout/src/lib.rs
max_diff
called by 1
ntest/src/traits.rs
collect_test_descriptions
called by 1
ntest_test_cases/src/lib.rs
lit_to_str
called by 1
ntest_test_cases/src/syn_helper.rs

Shape

Function 62
Class 2
Enum 1
Interface 1
Method 1

Languages

Rust100%

Modules by API surface

ntest/src/lib.rs20 symbols
ntest/tests/integration.rs12 symbols
ntest_timeout/tests/timeout.rs10 symbols
ntest_test_cases/tests/test_cases.rs10 symbols
ntest_test_cases/src/lib.rs7 symbols
ntest_timeout/src/lib.rs3 symbols
ntest_test_cases/src/syn_helper.rs3 symbols
ntest/src/traits.rs2 symbols

For agents

$ claude mcp add ntest \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page