Assure that your tests are there, and well written.

Overview

cargo-is-tested


[ 🇪🇸 ] El libro contiene instrucciones e información detallada en Español.


cargo-is-tested is a way to check which of your items are tested and which aren't, very configurable and with a scripting-friendly API ready to use with your Git hooks.

Also, is uses pretty colors for error reporting.

You can also read the book for a more user-friendly guide.

Example

To check if all functions are tested in the current directory.

$ cargo is-tested .
# Cargo.toml
# [...]

[dependencies]
is_tested = "0.1.1" # Check crates.io for the current version of the crate.

# [...]
// src/main.rs

#! is-tested functions
// Yes, it uses shebangs to enable testing and flags!

use is_tested::is_tested;

#[is_tested("test/myfunction_testing_path.rs")]
fn my_function() {
	// [...]
}

Then, it will check if test/myfunction_testing_path.rs exists, if it doesn't, it will output an error.

If the file exists, the program checks all lints against your test, assuring the best quality possible. For example, the lint emptiness will check that your functions aren't empty.

Installation and usage

To get started using cargo-is-tested, install the binary.

$ cargo install cargo-is-tested

Now document yourself about all the lints you can apply to your tests. You can also use strict to activate them all (currently, recommendable)

More lints will be added with time.


Once you know the lints you want to apply, import the attribute is_tested, then choose a struct, function or any item that you want to test, and add to that item the attribute #[is_tested("<path to the test>.rs")]

The result should be something like:

#! is-tested strict

use is_tested::is_tested;

#[is_tested("tests/mystruct.rs")]
struct MyStruct<'a> {
	string: &'a str
}

Don't worry, the attribute won't change anything in your code, it's just a marker for a later-parser to know that you're testing the item.


It's time to run the parser, it will read check that all tested items are tested, and with the correct code quality dicted using the lints.

// tests/mystruct.rs

use mycrate::MyStruct;

fn main() {
	// [...]
}
$ cargo is-tested .

This will check that all tests are well written. You can use flags to customize your experience, for example, use --structs to check that all structs have tests associated, or use --test to, if all tests are confirmed, run cargo test automatically.


Stargazers

Stargazers repo roster for @blyxyas/cargo-is-tested

License

cargo-is-tested uses the MIT License, 2023. You can check the LICENSE for more information about licensing.

You might also like...
A Yocto setup and management tool that helps you keep your environment up-to-date and in-sync with your team
A Yocto setup and management tool that helps you keep your environment up-to-date and in-sync with your team

yb (Yocto Buddy) yb is designed to make it easy to setup and (perhaps more importantly) keep Yocto environments up-to-date and in-sync with your team.

Get your loadshedding schedule in your calendar and never be left in the dark! Open-source, up-to-date, and developer friendly.
Get your loadshedding schedule in your calendar and never be left in the dark! Open-source, up-to-date, and developer friendly.

Loadshedding schedules in your digital calendar. No apps, no ads, up-to-date, and developer friendly. Get it • Key Features • Using the data • Project

🐢 Atuin replaces your existing shell history with a SQLite database, and records additional context for your commands
🐢 Atuin replaces your existing shell history with a SQLite database, and records additional context for your commands

Atuin replaces your existing shell history with a SQLite database, and records additional context for your commands. Additionally, it provides optional and fully encrypted synchronisation of your history between machines, via an Atuin server.

By mirroring traffic to and from your machine, mirrord surrounds your local service with a mirror image of its cloud environment.
By mirroring traffic to and from your machine, mirrord surrounds your local service with a mirror image of its cloud environment.

mirrord lets you easily mirror traffic from your Kubernetes cluster to your development environment. It comes as both Visual Studio Code extension and

Convert your favorite images and wallpapers with your favorite color palettes/themes
Convert your favorite images and wallpapers with your favorite color palettes/themes

dipc doprz' image palette converter Convert your favorite images and wallpapers with your favorite color palettes/themes Color Palettes/Themes catppuc

A filesystem driver that allows you to view your Blackboard course contents as if they were normal files and folders on your system!
A filesystem driver that allows you to view your Blackboard course contents as if they were normal files and folders on your system!

BlackboardFS Blackboard: noun A website so bad that it might as well be a network drive. BlackboardFS is a filesystem driver that allows you to view y

 A money tracker: Your income and expenses at your control
A money tracker: Your income and expenses at your control

NixBucks A simple budgeting app Install If you are on Linux, you can download the Appimage from the latest release (click here). Otherwise, you can in

Manage your dotfiles and packages with ease. Define your $HOME as Code  💻 🚀 ✨
Manage your dotfiles and packages with ease. Define your $HOME as Code 💻 🚀 ✨

EnvHub is a simple tool to manage dotfiles and packages accross multiple machines. Written in Rust, internally it uses nix/homebrew/pkgx/devbox to man

Save image from your clipboard 📋 as an image file directly from your command line! 🔥

Clpy 📋 Save copied image from clipboard as an image file directly from your command line! Note It works only on windows as of now. I'll be adding sup

Owner
Alex ✨ Cosmic Princess ✨
✌️ Hi! (she/her) Trying to not become a furry every midnight (hard task)
Alex ✨ Cosmic Princess ✨
Black-box integration tests for your REST API using the Rust and its test framework

restest Black-box integration test for REST APIs in Rust. This crate provides the [assert_api] macro that allows to declaratively test, given a certai

IOmentum 10 Nov 23, 2022
🐎 Just a simple cross-platform neofetch for all the bronies out there.

⚠️ (WIP) This project is not ready for any serious use right now. A cross-platform command-line interface (CLI) tool written in Rust to display system

Jakub 4 Dec 15, 2022
Utility for barcoderdev/unitypackage_godot, submit issues there.

unitypackage_util Requires barcoderdev/FBX2glTF to extract FBX in GLTF(glb) format. Place the binary in the same folder, or in PATH. Usage: unitypacka

Barcoder 4 May 25, 2023
A simple, opinionated way to run containers for tests in your Rust project.

rustainers rustainers is a simple, opinionated way to run containers for tests. TLDR More information about this crate can be found in the crate docum

wefox 4 Nov 23, 2023
A template with cookie cutter CLI, Program and Integration tests for Solana blockchain

About solana-cli-program template is a sample app demonstrating the creation of a minimal CLI application written in Rust to interact with Solana and

null 46 Nov 3, 2022
lemmy-help is a emmylua parser as well as a CLI which takes that parsed tree and converts it into vim help docs.

lemmy-help is a emmylua parser as well as a CLI which takes that parsed tree and converts it into vim help docs.

Vikas Raj 117 Jan 3, 2023
Yet Another Kalman Filter Implementation. As well as Lie Theory (Lie group and algebra) on SE(3). [no_std] is supported by default.

yakf - Yet Another Kalman Filter Yet Another Kalman Filter Implementation, as well as, Lie Theory (Lie group, algebra, vector) on SO(3), SE(3), SO(2),

null 7 Dec 1, 2022
Snapshot testing for a herd of CLI tests

trycmd Snapshot testing for a herd of CLI tests trycmd aims to simplify the process for running a large collection of end-to-end CLI test cases, takin

null 57 Jan 3, 2023
git-cliff can generate changelog files from the Git history by utilizing conventional commits as well as regex-powered custom parsers.⛰️

git-cliff can generate changelog files from the Git history by utilizing conventional commits as well as regex-powered custom parsers. The changelog template can be customized with a configuration file to match the desired format.

Orhun Parmaksız 5k Jan 9, 2023
A command line tool that resembles a debugger as well as Cheat Engine, to search for values in memory

Summary This is a small command-line tool designed to peek around memory of a running Linux process. It also provides filtering mechanisms similar to

null 213 Jul 4, 2023