https://github.com/assertj/assertj-assertions-generator-maven-plugin
A maven plugin to generate assertions for your custom types
https://github.com/assertj/assertj-assertions-generator-maven-plugin
Last synced: 4 months ago
JSON representation
A maven plugin to generate assertions for your custom types
- Host: GitHub
- URL: https://github.com/assertj/assertj-assertions-generator-maven-plugin
- Owner: assertj
- License: other
- Created: 2013-03-14T18:22:33.000Z (almost 13 years ago)
- Default Branch: main
- Last Pushed: 2023-08-17T13:07:12.000Z (over 2 years ago)
- Last Synced: 2025-07-30T18:40:37.478Z (6 months ago)
- Language: Java
- Homepage:
- Size: 178 KB
- Stars: 28
- Watchers: 8
- Forks: 25
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Maven plugin to generate AssertJ assertions
==
[](https://maven-badges.herokuapp.com/maven-central/org.assertj/assertj-assertions-generator-maven-plugin)
## Overview
This plugin can generate [AssertJ assertions](https://github.com/joel-costigliola/assertj-core) for your own classes via maven (it is based on [assertj-assertions-generator](https://github.com/joel-costigliola/assertj-assertions-generator)).
Let's say that you have a `Player` class with `name` and `team` attributes, the plugin is able to create a `PlayerAssert` assertions class with `hasName` and `hasTeam` assertions, to write code like :
```java
assertThat(mvp).hasName("Lebron James").hasTeam("Miami Heat");
```
The plugin can be launched with command `mvn generate-test-sources` (or simply `mvn test`) or with any IDE that supports maven.
By default, it generates the assertions source files in `target/generated-test-sources/assertions` as per maven convention (but this can be changed - see below).
**Example of plugin execution:**
```
====================================
AssertJ assertions generation report
====================================
--- Generator input parameters ---
Generating AssertJ assertions for classes in following packages and subpackages:
- org.assertj.examples.data
--- Generator results ---
Directory where custom assertions files have been generated :
- /home/joe/assertj/assertj-examples/target/generated-test-sources/assertj-assertions
Custom assertions files generated :
- TeamAssert.java
- BasketBallPlayerAssert.java
- EmployeeAssert.java
- NameAssert.java
- MagicalAssert.java
- PersonAssert.java
- RaceAssert.java
- GameServiceAssert.java
- MansionAssert.java
- TitleAssert.java
- AlignmentAssert.java
- TolkienCharacterAssert.java
- RingAssert.java
- MovieAssert.java
- TeamManagerAssert.java
Assertions entry point class has been generated in file:
- /home/joe/assertj/assertj-examples/target/generated-test-sources/assertj-assertions/org/assertj/examples/data/Assertions.java
```
## Documentation
Please have a look at the complete documentation in [**assertj.org assertions generator section**](http://joel-costigliola.github.io/assertj/assertj-assertions-generator-maven-plugin.html), including a [**quickstart guide**](http://joel-costigliola.github.io/assertj/assertj-assertions-generator-maven-plugin.html#quickstart).