在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):khmarbaise/maven-it-extension开源软件地址(OpenSource Url):https://github.com/khmarbaise/maven-it-extension开源编程语言(OpenSource Language):Java 98.6%开源软件介绍(OpenSource Introduction):Integration Testing Framework Extension
StateThe 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 OverviewThe 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 IdeaThe 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 StartThe General RequirementsThe requirements to write integration tests with the integration testing framework are the following:
The Maven ConfigurationThe first thing before you can run integration tests is to add the following dependencies
(as minimum) to your <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 The next part is to add <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 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 <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 PartiesWriting an integration test for a Maven plugin means you have to have three parties:
The Component codeThe 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.):
The Testing CodeThe 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
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>
}
}
The Project to Test WithThe project you would like to use as a foundation for your test of the plugin. This is located in a special location
under
The Executed TestAfter execution of the integration test the result will look like this:
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). ConclusionIf 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. BuildingIf you like to build the project from source yourself you need the following:
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 Concept and Background GuideThe 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. The background guide is a conclusion about the reason why I have started this project. GitHub PagesCurrently we have two states of site:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论