Skip to content

Test-Case v1.0.0

Choose a tag to compare

@frondeus frondeus released this 28 Jan 15:04
· 103 commits to master since this release

Overview

This crate provides #[test_case] procedural macro attribute that generates multiple parametrized tests using one body with different input parameters.
A test is generated for each data set passed in test_case attribute.
Under the hood, all test cases that share same body are grouped into mod, giving clear and readable test results.

New features

  • Added support for three new keywords: panics, matches and inconclusive which can be applied after => token.

    matches gives possibility to test patterns, like:

    #[test_case("foo" => matches Some(("foo", _)))]

    panics gives should_panic(expected="...") for one test_case:

    #[test_case(true  => panics "Panic error message" ; "This should panic")]
    #[test_case(false => None                         ; "But this should return None")]

    inconclusive ignores one specific test case.- thanks to @luke-biel

    #[test_case("42")]
    #[test_case("XX" ; "inconclusive - parsing letters temporarily doesn't work, but it's ok")]
    #[test_case("na" => inconclusive ())]

Major improvements

  • Added extra unit tests - thanks to @luke-biel
  • Replace parented_test_case with parsing test_case directly from args - thanks to @luke-biel
  • Added keeping trailing underscores in names - thanks to @rzumer

Minor improvements

  • Moved lazy-static dependency to dev-dependencies
  • Fixed README - thanks to @luke-biel and @drwilco

Upgraded dependencies

  • Upgraded insta to 0.12.0