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
Copy file name to clipboardExpand all lines: docs/features/customization.mdx
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ For example, suppose the `Product` entity must follow these business rules:
14
14
-`priceAmount` must be greater than or equal to `10`
15
15
-`priceAmount` must be less than or equal to `10000`
16
16
17
-
You can implement these rules using a custom generator by extending [`ObjectGeneratorBase<T>`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/generator/ObjectGeneratorBase.html):
17
+
You can implement these rules using a custom generator by extending [`ObjectGeneratorBase<T>`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/generator/ObjectGeneratorBase.html):
18
18
19
19
<JavaKotlinCodeBlock>
20
20
```java
@@ -49,9 +49,9 @@ class ProductGenerator : ObjectGeneratorBase<Product>() {
49
49
```
50
50
</JavaKotlinCodeBlock>
51
51
52
-
This custom generator creates a `Product` instance that adheres to the business constraints. It uses [`ResolutionContext`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/ResolutionContext.html) to generate supporting values like `id` and `name`, and applies explicit logic to generate a valid `priceAmount`.
52
+
This custom generator creates a `Product` instance that adheres to the business constraints. It uses [`ResolutionContext`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/ResolutionContext.html) to generate supporting values like `id` and `name`, and applies explicit logic to generate a valid `priceAmount`.
53
53
54
-
You can apply this custom generator using the [`@Customization`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/customization/Customization.html) annotation:
54
+
You can apply this custom generator using the [`@Customization`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/Customization.html) annotation:
55
55
56
56
<JavaKotlinCodeBlock>
57
57
```java
@@ -142,7 +142,7 @@ fun testMethod(product: Product, review: Review) {
142
142
```
143
143
</JavaKotlinCodeBlock>
144
144
145
-
Alternatively, if you prefer to encapsulate multiple generators into a single reusable configuration, you can extend [`CompositeCustomizer`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/customization/CompositeCustomizer.html):
145
+
Alternatively, if you prefer to encapsulate multiple generators into a single reusable configuration, you can extend [`CompositeCustomizer`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/CompositeCustomizer.html):
146
146
147
147
<JavaKotlinCodeBlock>
148
148
```java
@@ -312,7 +312,7 @@ class TestClass {
312
312
```
313
313
</JavaKotlinCodeBlock>
314
314
315
-
In this example, we use the [`set`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/customization/dsl/ArgumentCustomizationDsl.html#set(autoparams.customization.dsl.FunctionDelegate)) static method from the [`ArgumentCustomizationDsl`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/customization/dsl/ArgumentCustomizationDsl.html) class to customize the behavior of the `ResolutionContext`. Specifically:
315
+
In this example, we use the [`set`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/dsl/ArgumentCustomizationDsl.html#set(autoparams.customization.dsl.FunctionDelegate)) static method from the [`ArgumentCustomizationDsl`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/dsl/ArgumentCustomizationDsl.html) class to customize the behavior of the `ResolutionContext`. Specifically:
316
316
317
317
- The `product` property in any `Review` instance created by the context will be set to the `product` parameter of the test.
318
318
- Likewise, the `rating` property will be set to the `rating` parameter.
@@ -359,7 +359,7 @@ class TestClass {
359
359
```
360
360
</JavaKotlinCodeBlock>
361
361
362
-
The [`Factory<T>`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/generator/Factory.html) class provides a convenient way to create customized objects when working with a single type. It avoids managing an explicit resolution context and keeps the test focused on the instances under test.
362
+
The [`Factory<T>`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/generator/Factory.html) class provides a convenient way to create customized objects when working with a single type. It avoids managing an explicit resolution context and keeps the test focused on the instances under test.
363
363
364
364
:::note
365
365
@@ -376,7 +376,7 @@ The `set` method relies on the availability of parameter names at runtime. Howev
376
376
377
377
## Settable Properties
378
378
379
-
If a class follows the JavaBeans convention—meaning it has a no-arguments constructor and public setter methods—AutoParams can automatically populate its properties using the [`InstancePropertyWriter`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/processor/InstancePropertyWriter.html) customizer.
379
+
If a class follows the JavaBeans convention—meaning it has a no-arguments constructor and public setter methods—AutoParams can automatically populate its properties using the [`InstancePropertyWriter`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/processor/InstancePropertyWriter.html) customizer.
Copy file name to clipboardExpand all lines: docs/features/factory.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ import { JavaKotlinCodeBlock } from '@site/src/components/JavaKotlinCodeBlock';
7
7
8
8
# `Factory<T>` class
9
9
10
-
The [`Factory<T>`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/generator/Factory.html) class is useful when you need to generate multiple instances of the same type. It allows you to create single instances or collections of generated objects on demand.
10
+
The [`Factory<T>`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/generator/Factory.html) class is useful when you need to generate multiple instances of the same type. It allows you to create single instances or collections of generated objects on demand.
11
11
12
12
Here's an example:
13
13
@@ -31,4 +31,4 @@ fun testMethod() {
31
31
```
32
32
</JavaKotlinCodeBlock>
33
33
34
-
In this example, a `Factory<Product>` is created to produce `Product` instances. The [`get()`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/generator/Factory.html#get()) method creates a single instance, while [`getRange(n)`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/generator/Factory.html#getRange(int,autoparams.customization.Customizer...)) returns a list of `n` instances. This approach is particularly helpful when you need bulk data generation in your tests.
34
+
In this example, a `Factory<Product>` is created to produce `Product` instances. The [`get()`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/generator/Factory.html#get()) method creates a single instance, while [`getRange(n)`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/generator/Factory.html#getRange(int,autoparams.customization.Customizer...)) returns a list of `n` instances. This approach is particularly helpful when you need bulk data generation in your tests.
Copy file name to clipboardExpand all lines: docs/features/freeze-by.mdx
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,13 +7,13 @@ import { JavaKotlinCodeBlock } from '@site/src/components/JavaKotlinCodeBlock';
7
7
8
8
# `@FreezeBy` Annotation
9
9
10
-
The [`@FreezeBy`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/customization/FreezeBy.html) annotation enables fine-grained control over value freezing in tests. It allows you to freeze a single value and reuse it across multiple generation targets that match specific conditions, such as type or name. This helps improve test readability and ensures consistency among generated values.
10
+
The [`@FreezeBy`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/FreezeBy.html) annotation enables fine-grained control over value freezing in tests. It allows you to freeze a single value and reuse it across multiple generation targets that match specific conditions, such as type or name. This helps improve test readability and ensures consistency among generated values.
11
11
12
12
## Matching Strategies
13
13
14
14
AutoParams provides several matching strategies that determine which targets should receive the frozen value during object generation. The following examples illustrate some strategies:
Reuses the frozen value for targets whose types are interfaces that the frozen value's type implements.
78
78
@@ -116,7 +116,7 @@ AutoParams provides several matching strategies that determine which targets sho
116
116
117
117
In this example, `String` implements `CharSequence`, so the same value is reused for both `s1` and `chars`. `StringContainer` is not affected because its type is not an interface.
Reuses the frozen value for other targets with matching names.
122
122
@@ -210,7 +210,7 @@ In this example, the frozen value `s1` is reused for both `s2` (same type) and `
210
210
211
211
## Shorthand for `EXACT_TYPE`
212
212
213
-
Using [`@Freeze`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/customization/Freeze.html) is equivalent to `@FreezeBy(EXACT_TYPE)`. It's a convenient shorthand for the most common matching strategy.
213
+
Using [`@Freeze`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/Freeze.html) is equivalent to `@FreezeBy(EXACT_TYPE)`. It's a convenient shorthand for the most common matching strategy.
Copy file name to clipboardExpand all lines: docs/features/parameterized.mdx
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ Here are some of the features you can use for parameterized tests.
13
13
14
14
## `@ValueAutoSource` Annotation
15
15
16
-
The [`@ValueAutoSource`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/ValueAutoSource.html)(or `@ValueAutoKotlinSource`) annotation is a simple yet powerful tool for writing parameterized tests with AutoParams.
16
+
The [`@ValueAutoSource`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/ValueAutoSource.html)(or `@ValueAutoKotlinSource`) annotation is a simple yet powerful tool for writing parameterized tests with AutoParams.
17
17
18
18
<JavaKotlinCodeBlock>
19
19
```java
@@ -45,7 +45,7 @@ This feature depends on parameter name availability. See the note in the [One-ti
45
45
46
46
:::
47
47
48
-
In this example, the test method is executed twice—once with `"Camera"` and once with `"Candle"` as the value of the `name` parameter. The `factory` parameter is resolved automatically by AutoParams and can be customized using the DSL, as shown with [`freezeArgument`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/customization/dsl/ArgumentCustomizationDsl.html).
48
+
In this example, the test method is executed twice—once with `"Camera"` and once with `"Candle"` as the value of the `name` parameter. The `factory` parameter is resolved automatically by AutoParams and can be customized using the DSL, as shown with [`freezeArgument`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/customization/dsl/ArgumentCustomizationDsl.html).
49
49
50
50
This enables the creation of test objects (`Product` in this case) that are partially controlled (e.g., a fixed name) and partially randomized (e.g., all other properties), striking a balance between specificity and variety.
51
51
@@ -64,7 +64,7 @@ The usage of `@ValueAutoSource` is similar to JUnit 5's `@ValueSource`, and it s
64
64
65
65
## `@CsvAutoSource` Annotation
66
66
67
-
The [`@CsvAutoSource`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/CsvAutoSource.html)(or `@CsvAutoKotlinSource`) annotation lets you define repeated test inputs in CSV format, similar to JUnit 5’s @CsvSource. Any parameters not explicitly provided in the CSV rows will be automatically generated by AutoParams.
67
+
The [`@CsvAutoSource`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/CsvAutoSource.html)(or `@CsvAutoKotlinSource`) annotation lets you define repeated test inputs in CSV format, similar to JUnit 5’s @CsvSource. Any parameters not explicitly provided in the CSV rows will be automatically generated by AutoParams.
68
68
69
69
<JavaKotlinCodeBlock>
70
70
```java
@@ -100,7 +100,7 @@ This approach makes it easy to test combinations of fixed and dynamic values in
100
100
101
101
## `@MethodAutoSource` Annotation
102
102
103
-
The [`@MethodAutoSource`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/MethodAutoSource.html)(or `@MethodAutoKotlinSource`) annotation combines the features of JUnit 5’s `@MethodSource` and AutoParams’s `@AutoSource`. You can specify a method that provides test data, and AutoParams will fill in any remaining parameters automatically.
103
+
The [`@MethodAutoSource`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/MethodAutoSource.html)(or `@MethodAutoKotlinSource`) annotation combines the features of JUnit 5’s `@MethodSource` and AutoParams’s `@AutoSource`. You can specify a method that provides test data, and AutoParams will fill in any remaining parameters automatically.
104
104
105
105
<JavaKotlinCodeBlock>
106
106
```java
@@ -145,7 +145,7 @@ This setup allows you to blend manually specified values with automatically gene
145
145
146
146
## `@Repeat` Annotation
147
147
148
-
The [`@Repeat`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/Repeat.html) annotation allows you to run a test multiple times, generating fresh random values for unspecified parameters on each run.
148
+
The [`@Repeat`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/Repeat.html) annotation allows you to run a test multiple times, generating fresh random values for unspecified parameters on each run.
Copy file name to clipboardExpand all lines: docs/features/resolution-context.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ import { JavaKotlinCodeBlock } from '@site/src/components/JavaKotlinCodeBlock';
7
7
8
8
# `ResolutionContext` class
9
9
10
-
The [`ResolutionContext`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.0/autoparams/ResolutionContext.html) class provides the core mechanism for generating test data. While it is used internally by AutoParams, you can also instantiate and use it directly in your own test code when needed.
10
+
The [`ResolutionContext`](https://www.javadoc.io/static/io.github.autoparams/autoparams/11.0.1/autoparams/ResolutionContext.html) class provides the core mechanism for generating test data. While it is used internally by AutoParams, you can also instantiate and use it directly in your own test code when needed.
0 commit comments