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 :
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
请发表评论