configure jacoco for JUnit 5

This commit is contained in:
anhefti 2019-09-02 14:00:07 +02:00
parent 8c4d5c50f8
commit b9b8581075
2 changed files with 97 additions and 25 deletions

73
pom.xml
View file

@ -150,23 +150,64 @@
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<configuration>
<includes>
<include>ch/ethz/seb/sebserver/*</include>
</includes>
<!-- <excludes> -->
<!-- <exclude>ch/ethz/seb/sebserver/webservice/datalayer/batis/mapper/*</exclude> -->
<!-- <exclude>ch/ethz/seb/sebserver/webservice/datalayer/batis/model/*</exclude> -->
<!-- </excludes> -->
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution
data. -->
<dataFile>target/jacoco.exec</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>target/jacoco-ut</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<includes>
<include>ch/ethz/seb/sebserver/*</include>
</includes>
<excludes>
<exclude>ch/ethz/seb/sebserver/webservice/datalayer/batis/mapper/*</exclude>
<exclude>ch/ethz/seb/sebserver/webservice/datalayer/batis/model/*</exclude>
</excludes>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
<!-- <configuration> -->
<!-- <includes> -->
<!-- <include>ch/ethz/seb/sebserver/*</include> -->
<!-- </includes> -->
<!-- <excludes> -->
<!-- <exclude>ch/ethz/seb/sebserver/webservice/datalayer/batis/mapper/*</exclude> -->
<!-- <exclude>ch/ethz/seb/sebserver/webservice/datalayer/batis/model/*</exclude> -->
<!-- </excludes> -->
<!-- </configuration> -->
<!-- <executions> -->
<!-- <execution> -->
<!-- <id>default-prepare-agent</id> -->
<!-- <goals> -->
<!-- <goal>prepare-agent</goal> -->
<!-- </goals> -->
<!-- </execution> -->
<!-- </executions> -->
</plugin>
</plugins>
</build>
@ -312,14 +353,14 @@
<!-- Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View file

@ -11,6 +11,8 @@ package ch.ethz.seb.sebserver.gui.integration;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.springframework.core.annotation.Order;
import org.springframework.test.context.jdbc.Sql;
@ -22,18 +24,29 @@ import ch.ethz.seb.sebserver.gbl.util.Result;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestServiceImpl;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.institution.ActivateInstitution;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.institution.GetInstitution;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.institution.GetInstitutionNames;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.institution.NewInstitution;
@Sql(scripts = { "classpath:schema-test.sql", "classpath:data-test.sql" })
public class UseCasesIntegrationTest extends GuiIntegrationTest {
@BeforeAll
@Sql(scripts = { "classpath:schema-test.sql", "classpath:data-test.sql" })
public void init() {
}
@AfterAll
@Sql(scripts = { "classpath:schema-test.sql", "classpath:data-test.sql" })
public void cleanup() {
}
@Test
@Order(1)
public void bigUseCasesTest() {
// *************************************
// Use Case 1: SEB Administrator creates a new institution and activate this new institution
// *************************************
// Use Case 1: SEB Administrator creates a new institution and activate this new institution
public void testUsecase1() {
final RestServiceImpl restService = createRestServiceForUser(
"admin",
"admin",
@ -68,12 +81,30 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest {
assertEquals("Test Institution", institution.name);
assertTrue(institution.active);
// *************************************
// Use Case 2: SEB Administrator creates a new Institutional Administrator user for the
// newly created institution and activate this user
}
// TODO do as much use cases as possible within this integration test
@Test
@Order(2)
// *************************************
// Use Case 2: SEB Administrator creates a new Institutional Administrator user for the
// newly created institution and activate this user
public void testUsecase2() {
final RestServiceImpl restService = createRestServiceForUser(
"admin",
"admin",
new GetInstitution(),
new GetInstitutionNames());
final String instId = restService.getBuilder(GetInstitutionNames.class)
.call()
.getOrThrow()
.stream()
.filter(inst -> "Test Institution".equals(inst.name))
.findFirst()
.get().modelId;
assertNotNull(instId);
}
}