Skip to content

Commit af7f068

Browse files
committed
## Release Notes
- Feature: When annotated with `@Strict`, an Enum in a `@TestWithCases` will be checked for whether all enum-values are covered by test-cases
1 parent e0526f3 commit af7f068

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The purpose of this project is to generate full object graphs for use in test su
1818
<dependency>
1919
<groupId>com.github.nylle</groupId>
2020
<artifactId>javafixture</artifactId>
21-
<version>2.15.0</version>
21+
<version>2.16.0</version>
2222
<scope>test</scope>
2323
</dependency>
2424
```
@@ -327,6 +327,22 @@ void canCreateEnumFromString(TestEnum testEnum, String string) {
327327
}
328328
```
329329

330+
#### Enums can be Strictly Validated
331+
Adding the `@Strict`-annotation in front of an Enum will ensure that all enum-values are covered by `@TestCase`s.
332+
```java
333+
@TestWithCases
334+
@TestCase(str1 = "VALUE1", str2 = "VALUE1")
335+
@TestCase(str1 = "VALUE3", str2 = "VALUE3")
336+
void canCreateEnumFromString(@Strict TestEnum testEnum, String string) {
337+
assertThat(testEnum).isEqualTo(TestEnum.valueOf(string));
338+
}
339+
```
340+
This test will fail with a message similar to:
341+
```text
342+
@Strict requires all Enum values to be covered by test-cases. Missing values for arg0:
343+
TestEnum.VALUE2
344+
```
345+
330346
#### Random Injected Values
331347
If you are using `@TestWithFixture` and want to make the test parameterized, you can do so by using the annotation `@Fixture` inline:
332348
```java

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>com.github.nylle</groupId>
88
<artifactId>javafixture</artifactId>
99
<packaging>jar</packaging>
10-
<version>2.15.0</version>
10+
<version>2.16.0</version>
1111

1212
<name>JavaFixture</name>
1313
<url>https://github.com/Nylle/JavaFixture</url>

0 commit comments

Comments
 (0)