Maven Plugin Testing in a Modern Way - Part VI

Maven Plugin Testing in a Modern Way - Part VI

In this series on Maven plugin testing, we will take a deeper look how we can define profile(s) for a Maven call to be used.

In the previous part of the series - Maven Plugin Testing - In a Modern way - Part V, we have seen how to define system properties to run Maven. In this part we will take a deeper look how we can define profile(s) for a Maven call to be used.

Let us take a look at a simple example taken from the previous part.

Java

@MavenJupiterExtension
class BaseIT {
  @MavenTest
  @MavenGoal("verify")
  void the_first_test_case(MavenExecutionResult result) {
     ...
  }
}

This will run Maven with the goal verify. In real life it makes sometimes sense to run integration tests only by activating a profile like this:

Shell

mvn verify -Prun-its

So the question is now: How can we do that in the Integration Testing Framework? This can be achieved by using the @MavenProfile annotation like this:

Java

@MavenJupiterExtension
class BaseIT {
  @MavenTest
  @MavenGoal("verify")
  @MavenProfile("run-its")
  void the_first_test_case(MavenExecutionResult result) {
     ...
  }
}

This would execute our integration with the following command line (except the things we mentioned in previous parts of the series; Just omitted them for brevity.):

Shell

mvn verify -Prun-its

In the following example you can see that the @MavenProfile annotation used only on the method first:

Java

@MavenJupiterExtensio
class BaseIT {
  @MavenTest
  @MavenGoal("verify")
  @MavenProfile("run-its")
  void first(MavenExecutionResult result) {
     ...
  }
  @MavenTest
  void second(MavenExecutionResult result) {
     ...
  }
  @MavenTest
  void third(MavenExecutionResult result) 
     ...
  }0
}

java open source testing maven integration-testing

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Install OpenJDK 11 on CentOS 8

What is OpenJDK? OpenJDk or Open Java Development Kit is a free, open-source framework of the Java Platform, Standard Edition (or Java SE).

An Open-Source Book About the Open Source World

Open source today is a word that often include a lot of things, such as open knowledge (Wikimedia projects), open hardware (Arduino, Raspberry Pi), open formats (ODT/ODS/ODP) and so on.

Top 10 Automation Testing Tools: 2020 Edition

The demand for delivering quality software faster — or “Quality at Speed” — requires organizations to search for solutions in Agile, continuous integration (CI), and DevOps methodologies. Test automation is an essential part of these aspects.

Our New Open Source OAuth Integrations Manager

Pizzly is an OAuth Integrations Manager. It provides everything a developer needs to easily consume an OAuth-based API (aka an API that uses OAuth as the authentication method).

Testing Microservices Applications

The shift towards microservices and modular applications makes testing more important and more challenging at the same time. Learn more here.