#setup-teardown #before-each #teardown #after-each

macro test-helpers

Jest style setup and teardown test helper macros

1 unstable release

0.2.3 Mar 23, 2023

#4 in #before-each

Download history 4/week @ 2025-07-23 18/week @ 2025-07-30 48/week @ 2025-08-06 33/week @ 2025-08-13 83/week @ 2025-08-20 54/week @ 2025-08-27 42/week @ 2025-09-03 134/week @ 2025-09-10 34/week @ 2025-09-17 24/week @ 2025-09-24 35/week @ 2025-10-01 53/week @ 2025-10-08 48/week @ 2025-10-15 48/week @ 2025-10-22 3/week @ 2025-11-05

113 downloads per month

MIT license

25KB
354 lines

Build Status Crates.io Documentation

Description

Jest style setup and teardown test helpers.

Currently implemented:

  • #[after_all]: Only valid on a mod. Requires a single function named after_all. Counts the number of functions with a test attribute applied and runs the body of the after_all function after all the tests have run.

  • #[after_each]: Only valid on a mod. Requires a single function named after_each. Copies the body contents of the after_each function into the end of the function body of any functions in the same mod that have a test attribute applied.

  • #[before_all]: Only valid on a mod. Requires a single function named before_all. Runs the contents of before_all exactly once before any tests have run.

  • #[before_each]: Only valid on a mod. Requires a single function named before_each. Copies the body contents of the before_each function into the beginning of the function body of any functions in the same mod that have test attribute applied.

    • N.B. A function with a test attribute applied is any function with an attribute with the word test in it. So, #[test], #[tokio::test], and #[test_case(blah)] will all count for the before/after hooks.
  • #[skip]: Valid on a mod or an individual test. Will skip the mod or test it is applied on.

To do:

  • #[only]: Not sure how to implement this one, tbh.

Dependencies

~1.5MB
~39K SLoC