Skip to content

Commit

Permalink
build: bump cucumber to 7 and used junit bom
Browse files Browse the repository at this point in the history
The CucumberContextConfiguration does not work well with lambda's (cucumber-java8) hence I had to extract the configuration out of the stepdef as suggested in cucumber/cucumber-jvm#2413

Signed-off-by: Paul Williams <[email protected]>
  • Loading branch information
paul58914080 committed Nov 5, 2021
1 parent 61ddb83 commit 0076e50
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 52 deletions.
20 changes: 1 addition & 19 deletions acceptance-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,18 @@
<artifactId>cucumber-java8</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apiguardian</groupId>
<artifactId>apiguardian-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apiguardian</groupId>
<artifactId>apiguardian-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apiguardian</groupId>
<artifactId>apiguardian-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
package packagename.cucumber;

import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;

import io.cucumber.datatable.DataTable;
import io.cucumber.java8.En;
import io.cucumber.java8.HookNoArgsBody;
import io.cucumber.spring.CucumberContextConfiguration;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import packagename.boot.ExampleApplication;
import packagename.domain.model.Example;
import packagename.domain.model.ExampleInfo;
import packagename.repository.dao.ExampleDao;
import packagename.repository.entity.ExampleEntity;
import packagename.rest.exception.ExampleExceptionResponse;

@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = ExampleApplication.class, webEnvironment = RANDOM_PORT)
@CucumberContextConfiguration
@ActiveProfiles("test")
public class ExampleStepDef implements En {

private static final String LOCALHOST = "http://localhost:";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package packagename.cucumber;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
import static io.cucumber.junit.platform.engine.Constants.*;

@RunWith(Cucumber.class)
@CucumberOptions(
features = "classpath:features",
plugin = {"json:target/cucumber/example.json", "json:target/cucumber/example.xml"},
tags = "@Example",
glue = "classpath:packagename.cucumber")
import org.junit.platform.suite.api.ConfigurationParameter;
import org.junit.platform.suite.api.ConfigurationParameters;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.platform.suite.api.SelectClasspathResource;
import org.junit.platform.suite.api.Suite;

@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("features/example.feature")
@ConfigurationParameters({
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "packagename.cucumber"),
@ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "@Example"),
@ConfigurationParameter(key = JUNIT_PLATFORM_NAMING_STRATEGY_PROPERTY_NAME, value = "long"),
@ConfigurationParameter(key = PLUGIN_PUBLISH_QUIET_PROPERTY_NAME, value = "true"),
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "json:target/cucumber/cucumber.json")
})
public class RunCucumberExampleTest {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package packagename.cucumber;

import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;

import io.cucumber.spring.CucumberContextConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import packagename.boot.ExampleApplication;

@SpringBootTest(classes = ExampleApplication.class, webEnvironment = RANDOM_PORT)
@CucumberContextConfiguration
@ActiveProfiles("test")
public class SpringCucumberTestConfig {}
24 changes: 11 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<junit-jupiter.version>5.8.1</junit-jupiter.version>
<spring-boot.version>2.5.6</spring-boot.version>
<cucumber.version>6.11.0</cucumber.version>
<cucumber.version>7.0.0</cucumber.version>
<springdoc.version>1.5.12</springdoc.version>
<pre-liquibase.version>1.1.1</pre-liquibase.version>
<!-- plugins -->
Expand Down Expand Up @@ -63,6 +64,13 @@
<version>${project.version}</version>
</dependency>
<!-- Frameworks & Libraries -->
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit-jupiter.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
Expand Down Expand Up @@ -93,22 +101,12 @@
<!-- JUnit 5 dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
<!-- mockito dependencies -->
Expand Down

0 comments on commit 0076e50

Please sign in to comment.