Skip to content

Commit ae088b1

Browse files
committed
build: bump cucumber to 7 and used junit bom
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]>
1 parent e617f4a commit ae088b1

File tree

6 files changed

+35
-53
lines changed

6 files changed

+35
-53
lines changed

Diff for: acceptance-test/pom.xml

+1-19
Original file line numberDiff line numberDiff line change
@@ -31,36 +31,18 @@
3131
<artifactId>cucumber-java8</artifactId>
3232
<version>${cucumber.version}</version>
3333
<scope>test</scope>
34-
<exclusions>
35-
<exclusion>
36-
<artifactId>apiguardian-api</artifactId>
37-
<groupId>org.apiguardian</groupId>
38-
</exclusion>
39-
</exclusions>
4034
</dependency>
4135
<dependency>
4236
<groupId>io.cucumber</groupId>
43-
<artifactId>cucumber-junit</artifactId>
37+
<artifactId>cucumber-junit-platform-engine</artifactId>
4438
<version>${cucumber.version}</version>
4539
<scope>test</scope>
46-
<exclusions>
47-
<exclusion>
48-
<artifactId>apiguardian-api</artifactId>
49-
<groupId>org.apiguardian</groupId>
50-
</exclusion>
51-
</exclusions>
5240
</dependency>
5341
<dependency>
5442
<groupId>io.cucumber</groupId>
5543
<artifactId>cucumber-spring</artifactId>
5644
<version>${cucumber.version}</version>
5745
<scope>test</scope>
58-
<exclusions>
59-
<exclusion>
60-
<artifactId>apiguardian-api</artifactId>
61-
<groupId>org.apiguardian</groupId>
62-
</exclusion>
63-
</exclusions>
6446
</dependency>
6547
</dependencies>
6648
<build>

Diff for: acceptance-test/src/test/kotlin/packagename/AcceptanceTest.kt

-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import org.assertj.core.api.Assertions.assertThat
44
import org.assertj.core.api.Assertions.assertThatThrownBy
55
import org.junit.jupiter.api.Test
66
import org.junit.jupiter.api.extension.ExtendWith
7-
import org.junit.platform.runner.JUnitPlatform
8-
import org.junit.runner.RunWith
97
import org.mockito.Mock
108
import org.mockito.Mockito
119
import org.mockito.junit.jupiter.MockitoExtension
@@ -16,7 +14,6 @@ import packagename.domain.port.ObtainExample
1614
import java.util.*
1715

1816
@ExtendWith(MockitoExtension::class)
19-
@RunWith(JUnitPlatform::class)
2017
class AcceptanceTest {
2118

2219
@Test

Diff for: acceptance-test/src/test/kotlin/packagename/cucumber/ExampleStepDef.kt

-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ import packagename.repository.entity.ExampleEntity
2121
import packagename.rest.exception.ExampleExceptionResponse
2222

2323

24-
@ExtendWith(SpringExtension::class)
25-
@SpringBootTest(classes = [ExampleApplication::class], webEnvironment = RANDOM_PORT)
26-
@CucumberContextConfiguration
27-
@ActiveProfiles("test")
2824
class ExampleStepDef(restTemplate: TestRestTemplate, exampleDao: ExampleDao) : En {
2925

3026
companion object {
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package packagename.cucumber
22

3-
import io.cucumber.junit.Cucumber
4-
import io.cucumber.junit.CucumberOptions
5-
import org.junit.runner.RunWith
3+
import io.cucumber.junit.platform.engine.Constants.*
4+
import org.junit.platform.suite.api.*
65

7-
@RunWith(Cucumber::class)
8-
@CucumberOptions(features = ["classpath:features/example.feature"],
9-
strict = true,
10-
plugin = ["json:target/cucumber/example.json", "json:target/cucumber/example.xml"],
11-
tags = "@Example",
12-
glue = ["classpath:packagename.cucumber"])
6+
@Suite
7+
@IncludeEngines("cucumber")
8+
@SelectClasspathResource("features/example.feature")
9+
@ConfigurationParameters(
10+
ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "packagename.cucumber"),
11+
ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "@Example"),
12+
ConfigurationParameter(key = JUNIT_PLATFORM_NAMING_STRATEGY_PROPERTY_NAME, value = "long"),
13+
ConfigurationParameter(key = PLUGIN_PUBLISH_QUIET_PROPERTY_NAME, value = "true"),
14+
ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "json:target/cucumber/cucumber.json")
15+
)
1316
class RunCucumberExampleTest
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package packagename.cucumber
2+
3+
import io.cucumber.spring.CucumberContextConfiguration
4+
import org.springframework.boot.test.context.SpringBootTest
5+
import org.springframework.test.context.ActiveProfiles
6+
import packagename.boot.ExampleApplication
7+
8+
@SpringBootTest(classes = [ExampleApplication::class], webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
9+
@CucumberContextConfiguration
10+
@ActiveProfiles("test")
11+
class SpringCucumberTestConfig

Diff for: pom.xml

+11-18
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
<kotlin.version>1.5.31</kotlin.version>
1414
<maven.compiler.source>${java.version}</maven.compiler.source>
1515
<maven.compiler.target>${java.version}</maven.compiler.target>
16+
<junit-jupiter.version>5.8.1</junit-jupiter.version>
1617
<spring-boot.version>2.5.6</spring-boot.version>
17-
<cucumber.version>6.11.0</cucumber.version>
18+
<cucumber.version>7.0.0</cucumber.version>
1819
<springdoc.version>1.5.12</springdoc.version>
1920
<pre-liquibase.version>1.1.1</pre-liquibase.version>
2021
<!-- plugins -->
@@ -81,6 +82,13 @@
8182
<version>${project.version}</version>
8283
</dependency>
8384
<!-- Frameworks & Libraries -->
85+
<dependency>
86+
<groupId>org.junit</groupId>
87+
<artifactId>junit-bom</artifactId>
88+
<version>${junit-jupiter.version}</version>
89+
<type>pom</type>
90+
<scope>import</scope>
91+
</dependency>
8492
<dependency>
8593
<groupId>org.springframework.boot</groupId>
8694
<artifactId>spring-boot-dependencies</artifactId>
@@ -111,27 +119,12 @@
111119
<!-- JUnit 5 dependencies -->
112120
<dependency>
113121
<groupId>org.junit.jupiter</groupId>
114-
<artifactId>junit-jupiter-engine</artifactId>
115-
<scope>test</scope>
116-
</dependency>
117-
<dependency>
118-
<groupId>org.junit.platform</groupId>
119-
<artifactId>junit-platform-engine</artifactId>
120-
<scope>test</scope>
121-
</dependency>
122-
<dependency>
123-
<groupId>org.junit.vintage</groupId>
124-
<artifactId>junit-vintage-engine</artifactId>
125-
<scope>test</scope>
126-
</dependency>
127-
<dependency>
128-
<groupId>org.junit.platform</groupId>
129-
<artifactId>junit-platform-launcher</artifactId>
122+
<artifactId>junit-jupiter</artifactId>
130123
<scope>test</scope>
131124
</dependency>
132125
<dependency>
133126
<groupId>org.junit.platform</groupId>
134-
<artifactId>junit-platform-runner</artifactId>
127+
<artifactId>junit-platform-suite</artifactId>
135128
<scope>test</scope>
136129
</dependency>
137130
<!-- mockito dependencies -->

0 commit comments

Comments
 (0)