Adds integration test & edits Jenkins pipeline accordingly

This commit is contained in:
Philipp Czora 2017-10-05 10:00:45 +02:00
parent 67481fe73b
commit 3ca5d64a22
3 changed files with 275 additions and 222 deletions

10
Jenkinsfile vendored
View file

@ -18,7 +18,15 @@ node {
stage('Test') {
String jacoco = "org.jacoco:jacoco-maven-plugin:0.7.7.201606060606";
mvn "${jacoco}:prepare-agent verify ${jacoco}:report"
mvn "${jacoco}:prepare-agent test ${jacoco}:report"
// Archive JUnit results, if any
junit allowEmptyResults: true, testResults: '**/target/failsafe-reports/TEST-*.xml'
}
stage('Integration Test') {
String jacoco = "org.jacoco:jacoco-maven-plugin:0.7.7.201606060606";
mvn "${jacoco}:prepare-agent-integration failsafe:integration-test ${jacoco}:report-integration"
// Archive JUnit results, if any
junit allowEmptyResults: true, testResults: '**/target/surefire-reports/TEST-*.xml'

17
pom.xml
View file

@ -142,6 +142,20 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
@ -194,7 +208,8 @@
</execution>
</executions>
<configuration>
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory
</wroManagerFactory>
<cssDestinationFolder>${project.build.directory}/classes/static/resources/css</cssDestinationFolder>
<wroFile>${basedir}/src/main/wro/wro.xml</wroFile>
<extraConfigFile>${basedir}/src/main/wro/wro.properties</extraConfigFile>

View file

@ -0,0 +1,30 @@
package org.springframework.samples.petclinic.owner;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Ignore
public class OwnerControllerITCase {
@Autowired
private TestRestTemplate restTemplate;
/**
* Note: This test exists only for the purpose of serving as an example! Please write tests more sensible
* than this for your own applications.
*/
@Test
public void assertsUser1IsGeorgeFranklin() {
String body = this.restTemplate.getForObject("/owners/1", String.class);
assertThat(body).contains("<td><b>George Franklin</b></td>");
}
}