Giter Site home page Giter Site logo

assertj-assertions-generator-maven-plugin's Introduction

Maven plugin for assertj-assertions-generator

This plugin can generate AssertJ assertions for your own classes via maven (it is based on 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 :

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).

Big thanks to Michal Ostruszka for its major contribution on this plugin.

Releases

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

Configuration

You need to have AssertJ Core as a dependency in your pom.xml :

<dependency>
    <groupId>org.assertj</groupId>
    <artifactId>assertj-core</artifactId>
    <version>1.0.0</version>
    <scope>test</scope>
</dependency>

To generate custom assertions, add the following plugin to your pom.xml build/plugins section :

<plugin>
    <groupId>org.assertj</groupId>
    <artifactId>assertj-assertions-generator-maven-plugin</artifactId>
    <version>1.0.0</version>
    <configuration>
        <packages>
            <param>your.first.package</param>
            <param>your.second.package</param>
            ...
        </packages>
    </configuration>
</plugin>

... and execute the command :

mvn assertj:generate-assertions

packages configuration element is required so that the plugin knows where to find classes you want to generate assertions for.

You can also specify non-standard destination directory for assertion files using targetDir configuration element e.g.

<configuration>
    <packages>
        <param>your.first.package</param>
        <param>your.second.package</param>
        ...
    </packages>
    <targetDir>YOUR_NON_STANDARD_DIR</targetDir>
</configuration>

To generate assertions classes at every build, add an <executions> section as shown below :

<plugin>
    <groupId>org.assertj</groupId>
    <artifactId>assertj-assertions-generator-maven-plugin</artifactId>
    <version>1.0.0</version>
    <executions>
        <execution>
            <goals>
                <goal>generate-assertions</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <packages>
            <param>your.first.package</param>
            <param>your.second.package</param>
            ...
        </packages>
    </configuration>
</plugin>

Have good assertions !

assertj-assertions-generator-maven-plugin's People

Contributors

joel-costigliola avatar mostr avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.