Skip to content

twillouer/assertj-assertions-generator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to the AssertJ assertions generator project !

Overview

The Assertion Generator is able to create assertions specific to your own classes, it comes with :

Let's say that you have a Player class with name and team properties, the generator is able to create a PlayerAssert assertions class with hasName and hasTeam assertions, to write code like :

assertThat(mvp).hasName("Lebron James").hasTeam("Miami Heat");

Latest news

2013-09-15 : 1.1.0 release

  • Generated assertions use null safe equals for non primtive types
  • Add exceptions to assertion method signature if underlying getter of class to assert throws some (Fabien Duminy)
  • Generate assertions for nested/inner classes (Fabien Duminy)
  • Fix error message displaying unrelevant property value when getter of class to assert doesn't return the same value on successive calls (Fabien Duminy)

Big thanks to Fabien Duminy that has done most of the work of this release !

2013-03-26 : 1.0.0 release : the first release after Fest fork, generated assertions are cleaner.

Generate assertions from Maven

You should use the provided maven plugin.

Use with Eclipse

Work (not so much) in progress ...

We are developing an Eclipse plugin that allows you to generate assertions for a specific class (one at time only). Please check AssertJ eclipse plugin documentation.

Quickstart for NON Maven users

1 - Get AssertJ assertions generator

Get the AssertJ Assertions Generator 1.0.0 archive for unix or windows and extract it.

The archive structure is :

assertion-generator/
  |-- lib/
  |-- templates/
  |-- generate-assertions script (.bat or .sh)

2 - Generates assertions

  • Put in lib/ directory the jars containing the classes you want to generate assertions for .

  • Launch the scripts with either the classes or the packages containing the classes you want to generate assertions for.

Generate assertions for TolkienCharacter class :

generate-assertions.sh org.assertj.examples.data.TolkienCharacter 

Generate assertions for all classes in org.assertj.examples.data :

generate-assertions.sh org.assertj.examples.data 
  • your assertions classes have been generated, go find them in the current directory

Tip :
You can change what is generated by modifying the templates used for assertions creation (have a look at templates directory)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 94.9%
  • Shell 5.1%