All Projects → khmarbaise → maven-it-extension

khmarbaise / maven-it-extension

Licence: Apache-2.0 license
Experimental JUnit Jupiter Extension for writing integration tests for Maven plugins/Maven extensions/Maven Core

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects
HTML
75241 projects

Projects that are alternatives of or similar to maven-it-extension

pipeline-maven-plugin
Pipeline Maven Plugin
Stars: ✭ 50 (-10.71%)
Mutual labels:  maven, apache-maven
maven-jlink-plugin
Apache Maven JLink Plugin
Stars: ✭ 40 (-28.57%)
Mutual labels:  maven, maven-plugins
maven-wrapper-plugin
Apache Maven Wrapper Plugin
Stars: ✭ 14 (-75%)
Mutual labels:  maven, apache-maven
maven-deploy-plugin
Apache Maven Deploy Plugin
Stars: ✭ 30 (-46.43%)
Mutual labels:  apache-maven, maven-plugins
maven-shade-plugin
Apache Maven Shade Plugin
Stars: ✭ 120 (+114.29%)
Mutual labels:  maven, maven-plugins
maven-checkstyle-plugin
Apache Maven Checkstyle Plugin
Stars: ✭ 42 (-25%)
Mutual labels:  maven, maven-plugins
maven-javadoc-plugin
Apache Maven Javadoc Plugin
Stars: ✭ 45 (-19.64%)
Mutual labels:  maven, maven-plugins
Maven
Apache Maven core
Stars: ✭ 2,875 (+5033.93%)
Mutual labels:  maven, apache-maven
maven-dependency-plugin
Apache Maven Dependency Plugin
Stars: ✭ 119 (+112.5%)
Mutual labels:  maven, maven-plugins
maven-plugin-testing
Apache Maven Plugin Testing
Stars: ✭ 15 (-73.21%)
Mutual labels:  maven, maven-plugins
maven-install-plugin
Apache Maven Install Plugin
Stars: ✭ 21 (-62.5%)
Mutual labels:  maven, maven-plugins
maven-compiler-plugin
Apache Maven Compiler Plugin
Stars: ✭ 131 (+133.93%)
Mutual labels:  maven, maven-plugins
maven-wrapper
Apache Maven Wrapper
Stars: ✭ 128 (+128.57%)
Mutual labels:  maven, apache-maven
Beef
Business Entity Execution Framework
Stars: ✭ 95 (+69.64%)
Mutual labels:  integration-testing
docker-compose-integration-tests
Writing integration tests in Java using docker-compose and JUnit
Stars: ✭ 21 (-62.5%)
Mutual labels:  integration-testing
MasterAppiumFramework
Automation Testing | Mobile | Java | OOPS | Appium | TestNG | Maven | ExtentReport | Java mail API | Logging (Log4J2) | Design Patterns (Page Object Model, Singleton) | Page Factories | Jenkins | Data-Driven Testing using JSON file | Expected Data using XML file
Stars: ✭ 27 (-51.79%)
Mutual labels:  maven
faketime
Fake currentTimeMillis() without class loader hacks
Stars: ✭ 100 (+78.57%)
Mutual labels:  maven
duct
docker-compose alike functionality directly from golang, for integration testing.
Stars: ✭ 61 (+8.93%)
Mutual labels:  integration-testing
lagom-java-maven-chirper-example
No description or website provided.
Stars: ✭ 17 (-69.64%)
Mutual labels:  maven
nodejs-integration-testing
Integration testing of a Node.js / Express.js / Sequelize app
Stars: ✭ 23 (-58.93%)
Mutual labels:  integration-testing

Integration Testing Framework Extension

Apache License, Version 2.0, January 2004 Build Status Site Issues Issues Closed codecov

Release Maven Central Release Notes Users Guide
0.11.0 Maven Central PDF PDF
HTML HTML
0.12.0-SNAPSHOT Maven Central PDF PDF
HTML HTML

State

The project is in an early state but already being useful and can be used for real testing. The project release is available via Central repository (only the given version as show in above table) which makes it easy for you to use it out without the need to compile the code (You can of course do that if you like) yourself.

General Overview

The basic thing about integration testing of Maven Plugins / Maven Extensions etc. is currently that the existing solutions are not a very concise and comprehensive which is based on the long development history of the Apache Maven project. There are a lot of different approaches done over the time but from my perspective they all lack one thing: Simplicity. More detailed reasons etc. can be read in the Background Guide. This is the reason why I think it's time to come up with a more modern setup and started this project.

The Basic Idea

The basic idea rest upon the option to write custom extension with JUnit Jupiter for JUnit Jupiter testing framework which makes it very easy to get things done.

So in general the whole Integration Testing Framework in its core (itf-jupiter-extension) is a JUnit Jupiter extension which delivers supplemental support for a testing framework in general and in particular for using integration tests. Of course there is a lot of convenience integrated into it to make integration testing of Maven plugins easier.

Quick Start

The General Requirements

The requirements to write integration tests with the integration testing framework are the following:

  • JDK8+
  • Apache Maven 3.8.4 or above.

The Maven Configuration

The first thing before you can run integration tests is to add the following dependencies (as minimum) to your pom.xml:

<project..>
   ...
  <dependencies>
   <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.soebes.itf.jupiter.extension</groupId>
      <artifactId>itf-jupiter-extension</artifactId>
      <version>0.11.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
     <groupId>com.soebes.itf.jupiter.extension</groupId>
     <artifactId>itf-assertj</artifactId>
     <version>0.11.0</version>
     <scope>test</scope>
    </dependency>
  </dependencies>
  ..
</project..>

The first dependency org.junit.jupiter:junit-jupiter-engine is needed for JUnit Jupiter (We recommend the most recent version) working and the second one com.soebes.itf.jupiter.extension:itf-jupiter-extension is the extension to get support for running in general integration tests as described later. Finally, you have to add com.soebes.itf.jupiter.extension:itf-assertj which contains custom assertions based on AssertJ.

The next part is to add itf-maven-plugin in your pom.xml file like this which handles the first part which is involved:

<project...>
  ..
  <build>
    ..
    <plugin>
      <groupId>com.soebes.itf.jupiter.extension</groupId>
      <artifactId>itf-maven-plugin</artifactId>
      <version>0.11.0</version>
      <executions>
        <execution>
          <id>installing</id>
          <phase>pre-integration-test</phase>
          <goals>
            <goal>install</goal>
            <goal>resources-its</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    ..
  </build>
  ..
</project...>

The given version of itf-jupiter-extension as well as itf-maven-plugin should always be the most recent version which is available via Central repository.

Based on the concept we would like to run integration identified by the naming convention we have to add the maven-failsafe-plugin to the pom.xml like this (This will execute the integration tests which checks the functionality; The second part which is involved).

<project...>
  ..
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <configuration>
      <!--
       ! currently needed to run integration tests.
      -->
      <systemProperties>
        <maven.version>${maven.version}</maven.version>
        <maven.home>${maven.home}</maven.home>
      </systemProperties>
    </configuration>
    <executions>
      <execution>
        <goals>
          <goal>integration-test</goal>
          <goal>verify</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</project...>

Details about the given configuration can be read in the users guide.

The Involved Parties

Writing an integration test for a Maven plugin means you have to have three parties:

  1. The component you would like to test (typically a Maven plugin etc.).
  2. The testing code where you check the functionality.
  3. The Project you would like to test with (where your Maven plugin usually is configured in to be used.)

The Component code

The component you write is located in your project in the usual location. This is of course only an example of how it looks like in reality (usually more classes etc.):

.
└── src/
    └── main/
        └── java/
            └── org/
                └── plugin/
                    └── PluginMojo.java

The Testing Code

The structure for an integration tests follows of course the convention over configuration paradigm. Based on the conventions in Maven an integration test should be named like *IT.java and be located in the directory structure as follows:

.
└── src/
    └── test/
        └── java/
            └── org/
                └── it/
                    └── FirstMavenIT.java

So now the real a test code looks like this:

package org.it;

import static com.soebes.itf.extension.assertj.MavenITAssertions.assertThat;

import com.soebes.itf.jupiter.extension.MavenJupiterExtension;
import com.soebes.itf.jupiter.extension.MavenTest;
import com.soebes.itf.jupiter.maven.MavenExecutionResult;

import static com.soebes.itf.extension.assertj.MavenITAssertions.assertThat;

@MavenJupiterExtension // <1>
public class FirstMavenIT {

 @MavenTest // <2>
 void the_first_test_case(MavenExecutionResult result) { // <3>
  assertThat(result).isSuccessful(); // <4>
 }
 
}
  1. Maven Integration test annotation.
  2. Maven Test Annotation.
  3. Injected execution result
  4. Custom assertions to check the result of the build.

The Project to Test With

The project you would like to use as a foundation for your test of the plugin. This is located in a special location under src/test/resources-its/... This is needed to prevent the confusion with the usual src/test/resources in particular related to filtering etc. (details about the setup etc. in the users guide).

.
└── src/
    └── test/
        └── resources-its/
            └── org/
                └── it/
                    └── FirstMavenIT/
                        └── the_first_test_case/
                            ├── src/
                            └── pom.xml

The Executed Test

After execution of the integration test the result will look like this:

.
└──target/
   └── maven-it/
       └── org/
           └── it/
               └── FirstMavenIT/
                   └── the_first_test_case/
                       ├── .m2/
                       ├── project/
                       │   ├── src/
                       │   ├── target/
                       │   └── pom.xml
                       ├── mvn-stdout.log
                       ├── mvn-stderr.log
                       ├── mvn-arguments.log
                       └── orther logs.

This gives you a first impression how an integration test can look like. There are a lot of example in this project available and of course I strongly recommend reading the documentation (I know I don't like reading documentation either).

Conclusion

If you like the framework don't hesitate to test and give feedback in particular if things don't work as described or as you expected them to work.

Building

If you like to build the project from source yourself you need the following:

  • JDK 17+
  • Apache Maven 3.8.4+

The whole project can be built via:

mvn clean verify

This will take some time cause there are already integration tests in the itf-examples project which are executed and real integration tests for the itf-maven-plugin which is a bootstrap (eat-your-own-dog-food) to use already parts of the framework (JUnit Jupiter extension) to make the development of the plugin easier.

Concept and Background Guide

The concept guide describe my ideas I have in mind (just not to forget them). It is neither a roadmap nor about future releases etc. It's only intended to keep my ideas at a central location.

  • PDF
  • HTML

The background guide is a conclusion about the reason why I have started this project.

  • PDF
  • HTML

GitHub Pages

Currently we have two states of site:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].