[][src]Crate kevlar

Kevlar is a light-weight Test Harness that provides basic test features such as logging, setting up a test workspace, and managing the test result object, so that you can focus on writing your tests and the abstractions / support libraries that go along with them.

This crate is designed for writing test suites for testing other software.

If you just want to write unit tests, it is recommended to use Rust's built-in testing features instead.

use kevlar::*;
use std::path::PathBuf;
use async_trait::async_trait;
use log::*;

#[tokio::main]
async fn main() {
    let harness = TestHarness::new(
        "kevlar_example",
        ConfigType::File(PathBuf::from("./config.json")),
    );
    harness.run_async::<MyTest>().await;
}

#[derive(Default)]
struct MyTest;

#[async_trait]
impl AsyncTestCase for MyTest {
    async fn run_async(&mut self, _test_config: TestConfig, _test_result: &mut TestRecord) -> TestResult {
        info!("Do something interesting");
        Err(TestEvent::new(TestStatus::Failed).with_description("Something went wrong"))
    }
}

Structs

TestArtifact

Test Artifacts are files that your test generates or obtains during its life cycle. These can be passed to the TestHarness as part of a TestEvent. See TestRecord::add_event() for more details.

TestConfig
TestEvent

A TestEvent is any event that you want to highlight during the test. Typically this will be a test failure but you might also want to capture other events also.

TestHarness

The TestHarness struct provides all of the basic test framework features and functionality to your test. It takes care of all of the fundamentals so you don't have to.

TestRecord

The TestResult struct contains details about the test including the test name and current status. An instance of TestResult is owned and provided by the Test Harness to the test's run*() method.

Enums

ConfigType
TestArtifactType
TestStatus

Traits

AsyncTestCase

Implement the AsyncTestCase trait in order to run your test asynchronously. The run_async() method will be called by the Test Harness.

TestCase

Implement the TestCase trait in order to run your test synchronously. The run() method will be called by the Test Harness.

Type Definitions

TestResult