kevlar/
lib.rs

1//! Kevlar is a light-weight Test Harness that provides basic test features
2//! such as logging, setting up a test workspace, and managing the test
3//! result object, so that you can focus on writing your tests and the
4//! abstractions / support libraries that go along with them.
5//!
6//! This crate is designed for writing test suites for testing other software.
7//!
8//! If you just want to write unit tests, it is recommended to use Rust's
9//! [built-in testing features](https://doc.rust-lang.org/book/ch11-00-testing.html) instead.
10//!
11//! ```rust
12//! use kevlar::*;
13//! use std::path::PathBuf;
14//! use async_trait::async_trait;
15//! use log::*;
16//!
17//! #[tokio::main]
18//! async fn main() {
19//!     let harness = TestHarness::new(
20//!         "kevlar_example",
21//!         ConfigType::File(PathBuf::from("./config.json")),
22//!     );
23//!     harness.run_async::<MyTest>().await;
24//! }
25//!
26//! #[derive(Default)]
27//! struct MyTest;
28//!
29//! #[async_trait]
30//! impl AsyncTestCase for MyTest {
31//!     async fn run_async(&mut self, _test_config: TestConfig, _test_result: &mut TestRecord) -> TestResult {
32//!         info!("Do something interesting");
33//!         Err(TestEvent::new(TestStatus::Failed).with_description("Something went wrong"))
34//!     }
35//! }
36//! ```
37
38mod testcase;
39mod testconfig;
40mod testharness;
41mod testresult;
42
43// Convenience re-exports.
44pub use testcase::{AsyncTestCase, TestCase};
45pub use testconfig::{ConfigType, TestConfig};
46pub use testharness::TestHarness;
47pub use testresult::{
48    TestArtifact, TestArtifactType, TestEvent, TestRecord, TestResult, TestStatus,
49};
50
51#[cfg(test)]
52mod tests {
53    #[test]
54    fn it_works() {
55        assert_eq!(2 + 2, 4);
56    }
57}