You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which means the value-source mode is the only mode again; and for that reason the features were removed. The case-by-case mode is published as Yare on crates.io
Copy file name to clipboardExpand all lines: README.md
+37-76Lines changed: 37 additions & 76 deletions
Original file line number
Diff line number
Diff line change
@@ -1,41 +1,19 @@
1
1
# parameterized
2
2
3
-
Procedural macro which allows you to define a test to be run with multiple (optionally different) arguments.
4
-
Test cases are defined using the 'parameterized' attribute instead of the 'test' attribute.
3
+
Procedural macro based parameterized testing library.
4
+
Useful, when you want to run a test case with many different input sets.
5
+
6
+
When defining a parameterized test case, the `#[parameterized(...)]` attribute should be used instead of `#[test]`.
7
+
5
8
This crate was inspired by JUnit `@ParameterizedTest`.
6
9
7
10
### Examples:
8
11
9
12
Additional examples can be found at the <ahref="https://github.com/foresterre/parameterized-examples">parameterized-examples repository</a>,
10
-
the <ahref="https://github.com/foresterre/parameterized-example-usage">example-usage</a> crate in this repository and in the <ahref="parameterized-macro/tests">tests</a> folder.
13
+
and in the <ahref="parameterized-macro/tests">tests</a> folder.
11
14
12
15
<br>
13
16
14
-
**Example: Add5**
15
-
16
-
```rust
17
-
fnadd5<T:Into<u32>>(component:T) ->u32 {
18
-
component.into() +5
19
-
}
20
-
21
-
#[cfg(test)]
22
-
modtests {
23
-
usesuper::*;
24
-
useparameterized::parameterized;
25
-
26
-
ide!();
27
-
28
-
#[parameterized(input = {
29
-
0, 1, 2
30
-
}, expected = {
31
-
5, 6, 7
32
-
})]
33
-
fntest_add5(input:u16, expected:u32) {
34
-
assert_eq!(add5(input), expected);
35
-
}
36
-
}
37
-
```
38
-
39
17
**Example: Fruits**
40
18
41
19
```rust
@@ -73,6 +51,7 @@ impl NameOf for BrambleFruit {
73
51
74
52
#[cfg(test)]
75
53
modtests {
54
+
usesuper::*;
76
55
useparameterized::parameterized;
77
56
78
57
@@ -89,62 +68,44 @@ mod tests {
89
68
90
69
<br>
91
70
92
-
### Imports
71
+
**Example: Add5**
93
72
94
-
If you prefer not to import this library (with `use parameterized::parameterized;`) in every test module, you can put
95
-
the following snippet at the top of your crate root:
96
73
```rust
97
-
#[cfg(test)]
98
-
#[macro_use]
99
-
externcrate parameterized;
100
-
```
101
-
102
-
### Modes
74
+
fnadd5<T:Into<u32>>(component:T) ->u32 {
75
+
component.into() +5
76
+
}
103
77
104
-
This library consists of two modes: `valuesource` (the default mode, which is shown above) and `casebycase`.
105
-
The primary difference between these two modes is the way in which values are provided to the
106
-
`parameterized` macro. In case of `valuesource`, all values of a each parameter are given in as sequence, and each
107
-
sequence must have the same length, as each i-th element defines the inputs for a test case. A short example using
108
-
the syntax of this mode can be found below. Note here that the name of the formal parameter within the parameterized macro
109
-
should be equal to the name of the function it is defined on (`test`).
0 commit comments