Skip to content

Commit 7957ab6

Browse files
committed
simplify readme
1 parent c29e875 commit 7957ab6

File tree

1 file changed

+31
-78
lines changed

1 file changed

+31
-78
lines changed

README.md

Lines changed: 31 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
[![Javadoc](https://javadoc.io/badge2/io.github.romann-broque/fixture-annotations/javadoc.svg)](https://javadoc.io/doc/io.github.romann-broque/fixture-annotations)
55
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](./LICENSE)
66

7-
Stop wiring test objects by hand. Fixtures are now writing themselves. </br>
7+
Stop wiring test objects by hand. </br> ✨ Fixtures are now writing themselves. </br>
88

99
Annotate a `DataSet` and let the compiler produce a fluent `*Fixture` API (`buildDefault()`, `with…`, `without…`) so you can express test intent in a couple of lines.
1010

11-
- **`fixture-annotations`** — public annotations to mark your DataSet classes
12-
- **`fixture-processor`** — the annotation processor that generates fixture builders
11+
- **`fixture-annotations`**🏷️ public annotations to mark your DataSet classes
12+
- **`fixture-processor`**⚙️ the annotation processor that generates fixture builders
1313

14-
> Java 21+, Gradle 8+, Maven 3.9+. Works with plain JUnit and Spring Boot.
14+
> 🔧 Java 21+, Gradle 8+, Maven 3.9+. Works with plain JUnit and Spring Boot.
1515
1616
---
1717

18-
## Installation
18+
## 📦 Installation
1919

2020
### Gradle (Java)
2121

@@ -24,71 +24,20 @@ repositories { mavenCentral() }
2424
2525
// Generate fixtures for application sources (src/main/java)
2626
dependencies {
27-
implementation "io.github.romann-broque:fixture-annotations"
28-
annotationProcessor "io.github.romann-broque:fixture-processor"
27+
implementation "io.github.romann-broque:fixture-annotations:x.y.z"
28+
annotationProcessor "io.github.romann-broque:fixture-processor:x.y.z"
2929
}
3030
3131
// Generate fixtures for tests (src/test/java)
3232
dependencies {
33-
testImplementation "io.github.romann-broque:fixture-annotations"
34-
testAnnotationProcessor "io.github.romann-broque:fixture-processor"
33+
testImplementation "io.github.romann-broque:fixture-annotations:x.y.z"
34+
testAnnotationProcessor "io.github.romann-broque:fixture-processor:x.y.z"
3535
}
3636
3737
```
38-
39-
### Kotlin (KAPT)
40-
41-
```kotlin
42-
dependencies {
43-
implementation("io.github.romann-broque:fixture-annotations:x.y.z")
44-
kapt("io.github.romann-broque:fixture-processor:x.y.z")
45-
46-
// For tests:
47-
testImplementation("io.github.romann-broque:fixture-annotations:x.y.z")
48-
kaptTest("io.github.romann-broque:fixture-processor:x.y.z")
49-
}
50-
51-
```
52-
53-
### Maven
54-
55-
```xml
56-
<dependencies>
57-
<!-- Generate during main compilation -->
58-
<dependency>
59-
<groupId>io.github.romann-broque</groupId>
60-
<artifactId>fixture-annotations</artifactId>
61-
<version>x.y.z</version>
62-
</dependency>
63-
<dependency>
64-
<groupId>io.github.romann-broque</groupId>
65-
<artifactId>fixture-processor</artifactId>
66-
<version>x.y.z</version>
67-
<scope>provided</scope>
68-
</dependency>
69-
70-
<!-- OR generate during test compilation -->
71-
<!--
72-
<dependency>
73-
<groupId>io.github.romann-broque</groupId>
74-
<artifactId>fixture-annotations</artifactId>
75-
<version>x.y.z</version>
76-
<scope>test</scope>
77-
</dependency>
78-
<dependency>
79-
<groupId>io.github.romann-broque</groupId>
80-
<artifactId>fixture-processor</artifactId>
81-
<version>x.y.z</version>
82-
<scope>test</scope>
83-
</dependency>
84-
-->
85-
</dependencies>
86-
87-
```
88-
8938
---
9039

91-
## Usage example
40+
## 🧪 Usage example
9241

9342
Assuming you have a `Customer` model you want to test:
9443

@@ -135,21 +84,21 @@ public class Customer {
13584
}
13685
```
13786

138-
### Using the generated Fixture DSL
87+
### 🧩 Using the generated Fixture
13988

14089
You can create a `DataSet` class annotated with `@Fixture`.
14190
The annotation processor generates a fluent, chainable builder:
14291

143-
- `buildDefault()` → immediately builds the entity using **all default values** from your `DataModel`.
144-
- `defaultFixture()` → returns a **mutable builder** pre-filled with the `DataModel` defaults; call `build()` to create the entity.
145-
- `with<Field>(value)` → overrides a single field on the underlying `DataModel`.
146-
- `without<Field>()` → convenience for `with<Field>(null)` (sets the model field to `null`).
147-
- All `with…`/`without…` methods are **chainable**; **last call wins**.
92+
- `buildDefault()` → immediately builds the entity using **all default values** from your `DataModel`.
93+
- 🧱 `defaultFixture()` → returns a **mutable builder** pre-filled with the `DataModel` defaults; call `build()` to create the entity.
94+
- 🛠️ `with<Field>(value)` → overrides a single field on the underlying `DataModel`.
95+
- 🚫 `without<Field>()` → convenience for `with<Field>(null)` (sets the model field to `null`).
96+
- 🔗 All `with…`/`without…` methods are **chainable**; **last call wins**.
14897

149-
> Generated sources live under
98+
> 🗂️ Generated sources live under
15099
> `build/generated/sources/annotationProcessor/java/(main|test)/...`
151100
152-
### Minimal example
101+
### Minimal example
153102

154103
```java
155104
@GenerateFixture(entityClass = Customer.class, dataModelClass = CustomerDataSet.DataModel.class)
@@ -167,15 +116,15 @@ public class CustomerDataSet {
167116
}
168117
}
169118
```
170-
#### Build with defaults
119+
#### Build with defaults
171120

172121
```java
173122
// Exactly equivalent:
174123
Customer a = CustomerFixture.buildDefault();
175124
Customer b = CustomerFixture.defaultFixture().build();
176125
```
177126

178-
#### Override selected fields (with…) and chain
127+
#### ✏️ Override selected fields (with…) and chain
179128

180129
```java
181130
Customer c = CustomerFixture
@@ -186,7 +135,7 @@ Customer c = CustomerFixture
186135
.build();
187136
```
188137

189-
#### Explicitly null a field (without…)
138+
#### 🚫 Explicitly null a field (without…)
190139

191140
```java
192141
Customer d = CustomerFixture
@@ -200,7 +149,7 @@ assertThrows(CustomerException.class, () ->
200149
CustomerFixture.defaultFixture().withoutEmail().build()
201150
);
202151
```
203-
#### Combine with… and without… freely (order doesn’t matter; last wins)
152+
#### 🔀 Combine with… and without… freely (order doesn’t matter; last wins)
204153

205154
```java
206155
Customer e = CustomerFixture
@@ -212,7 +161,7 @@ Customer e = CustomerFixture
212161
.build();
213162
```
214163

215-
#### Parameterized tests stay clean and intention-revealing
164+
#### 🔁 Parameterized tests stay clean and intention-revealing
216165

217166
```java
218167
@ParameterizedTest
@@ -229,22 +178,26 @@ static Stream<Arguments> validAdultBirthDateProvider() {
229178
);
230179
}
231180
```
181+
### 🎉 That's it!
182+
Once you created the `DataSet` class, the fixture will be generated at compile time.
183+
So build your project, and start using the generated `*Fixture` class in your tests.
184+
232185
---
233186

234-
## Additional resources
187+
## 📚 Additional resources
235188

236189
- https://refactoring.guru/design-patterns/builder
237190
- https://ardalis.com/improve-tests-with-the-builder-pattern-for-test-data/
238191

239-
## Thanks
192+
## 🙏 Thanks
240193

241194
Special thanks to [Frédéric Foissey](https://github.com/ffoissey) for the original idea and initial implementation of these modules. The current codebase extends and maintains his initial work.
242195

243-
## Contributing
196+
## 🤝 Contributing
244197

245198
Issues and PRs are welcome. Please include a minimal reproduction for bugs.
246199

247-
## Notices & License
200+
## 📄 Notices & License
248201

249202
- License: [Apache-2.0](./LICENSE)
250203
- Notices: see [NOTICE](./NOTICE)

0 commit comments

Comments
 (0)