File tree 1 file changed +46
-0
lines changed
1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,52 @@ use proc_macro::TokenStream;
2
2
3
3
mod property_test;
4
4
5
+ /// The `property_test` procedural macro simplifies the creation of property-based tests
6
+ /// using the `proptest` crate. This macro provides a more concise syntax for writing tests
7
+ /// that automatically generate test cases based on properties.
8
+ ///
9
+ /// # Example
10
+ ///
11
+ /// Using the `property_test` macro:
12
+ ///
13
+ /// ```
14
+ /// #[property_test]
15
+ /// fn foo(x: i32) {
16
+ /// assert_eq!(x, x);
17
+ /// }
18
+ /// ```
19
+ ///
20
+ /// is roughly equivalent to:
21
+ ///
22
+ /// ```
23
+ /// proptest! {
24
+ /// #[test]
25
+ /// fn foo(x in any::<i32>()) {
26
+ /// assert_eq!(x, x);
27
+ /// }
28
+ /// }
29
+ /// ```
30
+ ///
31
+ /// # Details
32
+ ///
33
+ /// The `property_test` macro is used to define property-based tests, where the parameters
34
+ /// of the test function are automatically generated by `proptest`. The macro takes care
35
+ /// of setting up the test harness and generating input values, allowing the user to focus
36
+ /// on writing the test logic.
37
+ ///
38
+ /// # Attributes
39
+ ///
40
+ /// The `property_test` macro can take an optional `config` attribute, which allows you to
41
+ /// customize the configuration of the `proptest` runner.
42
+ ///
43
+ /// E.g. running 100 cases:
44
+ ///
45
+ /// ```rust
46
+ /// #[property_test(config = "ProptestConfig { cases: 100, .. ProptestConfig::default() }")]
47
+ /// fn foo(x: i32) {
48
+ /// assert_eq!(x, x);
49
+ /// }
50
+ /// ```
5
51
#[ proc_macro_attribute]
6
52
pub fn property_test ( attr : TokenStream , item : TokenStream ) -> TokenStream {
7
53
property_test:: property_test ( attr. into ( ) , item. into ( ) ) . into ( )
You can’t perform that action at this time.
0 commit comments