Commit 7842f50e authored by Stephane Nicoll's avatar Stephane Nicoll

Add property to skip integration tests

Generalize the `skip` property to start and stop goals so that one
can control if the Spring Boot app is starting via a configuration
property.

Note that this only controls the Spring Boot Maven plugin and the
failsafe maven plugin should be updated accordingly.

Closes gh-4922
parent 6c5441d0
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.boot.maven.it</groupId>
<artifactId>start-stop-skip</artifactId>
<version>0.0.1.BUILD-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
/*
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.test;
/**
* This sample should not run at all
*/
public class SampleApplication {
public static void main(String[] args) throws Exception {
System.out.println("Ooops, I haz been run");
}
}
import static org.junit.Assert.assertFalse
def file = new File(basedir, "build.log")
assertFalse 'Application should not have run', file.text.contains("Ooops, I haz been run")
assertFalse 'Should not attempt to stop the app', file.text.contains('Stopping application')
...@@ -151,6 +151,13 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { ...@@ -151,6 +151,13 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
@Parameter(property = "useTestClasspath", defaultValue = "false") @Parameter(property = "useTestClasspath", defaultValue = "false")
private Boolean useTestClasspath; private Boolean useTestClasspath;
/**
* Skip the execution.
* @since 1.3.2
*/
@Parameter(defaultValue = "false")
private boolean skip;
/** /**
* Specify if the application process should be forked. * Specify if the application process should be forked.
* @return {@code true} if the application process should be forked * @return {@code true} if the application process should be forked
...@@ -170,6 +177,10 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { ...@@ -170,6 +177,10 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
@Override @Override
public void execute() throws MojoExecutionException, MojoFailureException { public void execute() throws MojoExecutionException, MojoFailureException {
if (this.skip) {
getLog().debug("skipping run as per configuration.");
return;
}
final String startClassName = getStartClass(); final String startClassName = getStartClass();
run(startClassName); run(startClassName);
} }
......
...@@ -62,8 +62,19 @@ public class StopMojo extends AbstractMojo { ...@@ -62,8 +62,19 @@ public class StopMojo extends AbstractMojo {
@Parameter @Parameter
private int jmxPort = 9001; private int jmxPort = 9001;
/**
* Skip the execution.
* @since 1.3.2
*/
@Parameter(defaultValue = "false")
private boolean skip;
@Override @Override
public void execute() throws MojoExecutionException, MojoFailureException { public void execute() throws MojoExecutionException, MojoFailureException {
if (this.skip) {
getLog().debug("skipping stop as per configuration.");
return;
}
getLog().info("Stopping application..."); getLog().info("Stopping application...");
try { try {
if (Boolean.TRUE.equals(this.fork)) { if (Boolean.TRUE.equals(this.fork)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment