#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

#161 in Testing

Download history 1734/week @ 2022-04-25 1122/week @ 2022-05-02 1493/week @ 2022-05-09 1311/week @ 2022-05-16 1402/week @ 2022-05-23 1266/week @ 2022-05-30 1302/week @ 2022-06-06 1377/week @ 2022-06-13 1283/week @ 2022-06-20 1301/week @ 2022-06-27 1458/week @ 2022-07-04 1485/week @ 2022-07-11 1669/week @ 2022-07-18 2077/week @ 2022-07-25 2987/week @ 2022-08-01 2054/week @ 2022-08-08

9,006 downloads per month
Used in 15 crates (2 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

~230–640KB
~15K SLoC