Skip to content

Add Example for Testing with Custom Test Function Input #364

@flamewalker103-commits

Description

@flamewalker103-commits

Problem

The current README provides a good overview of how to set up and use datatest-stable, but it lacks a practical example involving a custom test function that takes multiple types of inputs (e.g., both a Path and file contents).

Suggested Improvement

It would be helpful to include an example that demonstrates how to define a custom test function that takes both a Path and a String (or Vec<u8>). For instance, an example function could show how to validate data from the file fixture and the file's path together. This would enhance understanding for users who wish to leverage both parameters in their tests.

Example Code

Here’s a potential addition to the README:

fn my_custom_test(path: &Path, contents: String) -> datatest_stable::Result<()> {
    // Implement your test logic here, for example:
    assert!(contents.len() > 0, "File at {:?} should not be empty", path);
    // Further testing logic...
}

datatest_stable::harness! {
    { test = my_custom_test, root = "path/to/fixtures", pattern = r".*\.txt" },
}

Including this example in the README would likely assist users in understanding the versatility of the datatest-stable framework.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions