#proc-macro #testing

macro interpolate_name

Simple procedural macro attribute for repetitive tests

7 releases

0.2.3 Aug 25, 2019
0.2.2 May 10, 2019
0.2.1 Mar 3, 2019
0.2.0 Feb 24, 2019
0.1.1 Aug 10, 2018

#242 in #proc-macro

Download history 4248/week @ 2022-11-29 4116/week @ 2022-12-06 3003/week @ 2022-12-13 3013/week @ 2022-12-20 2420/week @ 2022-12-27 3949/week @ 2023-01-03 3872/week @ 2023-01-10 2583/week @ 2023-01-17 3172/week @ 2023-01-24 2966/week @ 2023-01-31 2869/week @ 2023-02-07 3197/week @ 2023-02-14 2765/week @ 2023-02-21 2942/week @ 2023-02-28 3051/week @ 2023-03-07 2751/week @ 2023-03-14

12,072 downloads per month
Used in 17 crates (4 directly)

MIT license

8KB
137 lines

Procedural macro attribute to do not repeat yourself while testing

Usage

#[macro_use]
extern crate interpolate_name;

use interpolate_name::interpolate_test;

#[interpolate_test(foo, "foo")]
#[interpolate_test(bar, "bar")]
#[interpolate_test(baz, "baz")]
fn testme(f: &str) {
    println!("testing {}", f);
}

Produces

running 3 tests
test testme_baz ... ok
test testme_bar ... ok
test testme_foo ... ok

lib.rs:

interpolate_name

interpolate_name consists in a set of procedural macro attributes geared towards reduce the boilerplate while writing repetitive tests.

  • interpolate_test: a quick way to test the same function by passing specific arguments and have a test entry for each of them.
  • interpolate_name: a simple function renamer that can be combined with macros to support more complex patterns.

Dependencies

~0.6–1MB
~25K SLoC