Expand description
This library provides miscellaneous utility functions for unit and integration tests in Rust.
§Crate Features
Most crate features are enabled by default. The only exception are overly-specific features that are costly to build.
Not enabled by default:
server
:- Enables support for
TestServer
. - Includes the
warp
andtokio
re-exports.
- Enables support for
All other features are enabled by default:
diff
: support for the text diff functions.exec
: support for the binary execution functions.temp
: helpers for managing temporary directories and files.testdata
: support for file based tests.text
: text utility functions.
To disable the default features and opt into specific ones, change the
dependency in your Cargo.toml
:
[dependencies]
tux = { version = "...", default-features = false, features = ["..."] }
Re-exports§
Modules§
- assert_
panic - diff
- Utilities for computing the difference between sequences.
- text
- General text utilities for tests.
Macros§
- assert_
panic - Asserts that an expression panics with the specified message.
Structs§
- TempDir
- Manages a temporary directory that can be used by tests. Supports creating files in the directory. Once the value is dropped the entire directory and its contents are deleted.
- Test
Server - Provides a very simple HTTP server with
warp
that can be used to test requests.
Functions§
- get_bin
- Returns a
Command
for running a binary from the project (i.e. a binary built by Cargo). - get_
process_ output - Utility function to retrieve the standard output of a process from
the
std::process::Output
while validating the exit status and error output. - run_bin
- Convenience function combining
get_bin
andget_process_output
. - temp_
dir - Generates a temporary directory that can be used by tests. Returns
a
TempDir
value that provides access to the created directory. - testdata
- Test all
.input
files in the given directory (recursively) using the callback and compare the result with the expected output provided by a.valid
file alongside the input.