Skip to content

Commit f8d62ee

Browse files
authored
chore: add integration tests (#77)
* chore: add integration tests Signed-off-by: Todd Baert <[email protected]> * improve POM spacing Signed-off-by: Todd Baert <[email protected]> Signed-off-by: Todd Baert <[email protected]>
1 parent 2eec1a5 commit f8d62ee

File tree

9 files changed

+437
-4
lines changed

9 files changed

+437
-4
lines changed

.github/workflows/pullrequest.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ permissions:
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12+
services:
13+
flagd:
14+
image: ghcr.io/open-feature/flagd-testbed:latest
15+
ports:
16+
- 8013:8013
17+
1218
steps:
1319
- name: Check out the code
1420
uses: actions/checkout@v3
@@ -28,7 +34,7 @@ jobs:
2834
${{ runner.os }}-maven-
2935
3036
- name: Build with Maven
31-
run: mvn --batch-mode --update-snapshots verify
37+
run: mvn --batch-mode --update-snapshots verify -P integration-test
3238

3339
- name: Upload coverage to Codecov
3440
uses: codecov/codecov-action@v2

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "test-harness"]
2+
path = test-harness
3+
url = https://github.com/open-feature/test-harness

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ We hold regular meetings which you can see [here](https://github.com/open-featur
112112

113113
We are also present on the `#openfeature` channel in the [CNCF slack](https://slack.cncf.io/).
114114

115+
## Developing
116+
117+
### Integration tests
118+
119+
The continuous integration runs a set of [gherkin integration tests](https://github.com/open-feature/test-harness/blob/main/features/evaluation.feature) using [`flagd`](https://github.com/open-feature/flagd). These tests do not run with the default maven profile. If you'd like to run them locally, you can start the flagd testbed with `docker run -p 8013:8013 ghcr.io/open-feature/flagd-testbed:latest` and then run `mvn test -P integration-test`.
120+
115121
## Releasing
116122

117123
See [releasing](./docs/release.md).

pom.xml

+121-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<maven.compiler.source>1.8</maven.compiler.source>
1212
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
1313
<junit.jupiter.version>5.8.1</junit.jupiter.version>
14+
<!-- exclusion expression for integration tests -->
15+
<testExclusions>**/integration/*.java</testExclusions>
1416
</properties>
1517

1618
<name>OpenFeature Java SDK</name>
@@ -46,7 +48,6 @@
4648
<scope>provided</scope>
4749
</dependency>
4850

49-
5051
<dependency>
5152
<!-- used so that lombok can generate suppressions for spotbugs. It needs to find it on the relevant classpath -->
5253
<groupId>com.github.spotbugs</groupId>
@@ -96,29 +97,81 @@
9697
<version>${junit.jupiter.version}</version>
9798
<scope>test</scope>
9899
</dependency>
100+
99101
<dependency>
100102
<groupId>org.junit.jupiter</groupId>
101103
<artifactId>junit-jupiter-api</artifactId>
102104
<version>${junit.jupiter.version}</version>
103105
<scope>test</scope>
104106
</dependency>
107+
105108
<dependency>
106109
<groupId>org.junit.jupiter</groupId>
107110
<artifactId>junit-jupiter-params</artifactId>
108111
<version>${junit.jupiter.version}</version>
109112
<scope>test</scope>
110113
</dependency>
114+
111115
<dependency>
112116
<groupId>org.junit.platform</groupId>
113117
<artifactId>junit-platform-suite</artifactId>
114-
<version>1.8.1</version>
118+
<version>1.9.0</version>
119+
<scope>test</scope>
120+
</dependency>
121+
122+
<dependency>
123+
<groupId>io.cucumber</groupId>
124+
<artifactId>cucumber-java</artifactId>
115125
<scope>test</scope>
116126
</dependency>
127+
128+
<dependency>
129+
<groupId>io.cucumber</groupId>
130+
<artifactId>cucumber-junit-platform-engine</artifactId>
131+
<scope>test</scope>
132+
</dependency>
133+
134+
<dependency>
135+
<groupId>com.google.guava</groupId>
136+
<artifactId>guava</artifactId>
137+
<version>31.1-jre</version>
138+
<scope>test</scope>
139+
</dependency>
140+
141+
<dependency>
142+
<groupId>dev.openfeature.contrib.providers</groupId>
143+
<artifactId>flagd</artifactId>
144+
<version>0.3.2</version>
145+
<scope>test</scope>
146+
</dependency>
147+
117148
</dependencies>
118149

150+
<dependencyManagement>
151+
<dependencies>
152+
153+
<dependency>
154+
<groupId>io.cucumber</groupId>
155+
<artifactId>cucumber-bom</artifactId>
156+
<version>7.5.0</version>
157+
<type>pom</type>
158+
<scope>import</scope>
159+
</dependency>
160+
161+
<dependency>
162+
<groupId>org.junit</groupId>
163+
<artifactId>junit-bom</artifactId>
164+
<version>5.9.0</version>
165+
<type>pom</type>
166+
<scope>import</scope>
167+
</dependency>
168+
169+
</dependencies>
170+
</dependencyManagement>
119171

120172
<build>
121173
<plugins>
174+
122175
<plugin>
123176
<artifactId>maven-dependency-plugin</artifactId>
124177
<version>3.3.0</version>
@@ -137,16 +190,21 @@
137190
<ignoredUnusedDeclaredDependency>org.junit*</ignoredUnusedDeclaredDependency>
138191
</ignoredUnusedDeclaredDependencies>
139192
<ignoredDependencies>
193+
<ignoredDependency>com.google.guava*</ignoredDependency>
194+
<ignoredDependency>io.cucumber*</ignoredDependency>
195+
<ignoredDependency>org.junit*</ignoredDependency>
140196
<ignoredDependency>com.google.code.findbugs*</ignoredDependency>
141197
<ignoredDependency>com.github.spotbugs*</ignoredDependency>
142198
<ignoredDependency>uk.org.lidalia:lidalia-slf4j-ext:*</ignoredDependency>
143199
</ignoredDependencies>
144200
</configuration>
145201
</plugin>
202+
146203
<plugin>
147204
<artifactId>maven-compiler-plugin</artifactId>
148205
<version>3.8.1</version>
149206
</plugin>
207+
150208
<plugin>
151209
<groupId>org.apache.maven.plugins</groupId>
152210
<artifactId>maven-surefire-plugin</artifactId>
@@ -155,6 +213,10 @@
155213
<argLine>
156214
${surefireArgLine}
157215
</argLine>
216+
<excludes>
217+
<!-- tests to exclude -->
218+
<exclude>${testExclusions}</exclude>
219+
</excludes>
158220
</configuration>
159221
</plugin>
160222

@@ -224,7 +286,7 @@
224286
</rule>
225287
</rules>
226288
</configuration>
227-
</execution>
289+
</execution>
228290

229291
</executions>
230292
</plugin>
@@ -257,6 +319,7 @@
257319
</execution>
258320
</executions>
259321
</plugin>
322+
260323
<plugin>
261324
<groupId>org.apache.maven.plugins</groupId>
262325
<artifactId>maven-javadoc-plugin</artifactId>
@@ -372,6 +435,61 @@
372435
</plugins>
373436
</build>
374437

438+
<profiles>
439+
<profile>
440+
<!-- this profile handles running the flagd integration tests -->
441+
<id>integration-test</id>
442+
<properties>
443+
<!-- run the integration tests by clearing the exclusions -->
444+
<testExclusions></testExclusions>
445+
</properties>
446+
<build>
447+
<plugins>
448+
<!-- pull the gherkin tests as a git submodule -->
449+
<plugin>
450+
<groupId>org.codehaus.mojo</groupId>
451+
<artifactId>exec-maven-plugin</artifactId>
452+
<version>3.1.0</version>
453+
<executions>
454+
<execution>
455+
<id>update-test-harness-submodule</id>
456+
<phase>validate</phase>
457+
<goals>
458+
<goal>exec</goal>
459+
</goals>
460+
<configuration>
461+
<!-- run: git submodule update \-\-init \-\-recursive -->
462+
<executable>git</executable>
463+
<arguments>
464+
<argument>submodule</argument>
465+
<argument>update</argument>
466+
<argument>--init</argument>
467+
<argument>--recursive</argument>
468+
</arguments>
469+
</configuration>
470+
</execution>
471+
<execution>
472+
<id>copy-gherkin-tests</id>
473+
<phase>validate</phase>
474+
<goals>
475+
<goal>exec</goal>
476+
</goals>
477+
<configuration>
478+
<!-- run: cp test-harness/features/evaluation.feature src/test/resources/features/ -->
479+
<executable>cp</executable>
480+
<arguments>
481+
<argument>test-harness/features/evaluation.feature</argument>
482+
<argument>src/test/resources/features/</argument>
483+
</arguments>
484+
</configuration>
485+
</execution>
486+
</executions>
487+
</plugin>
488+
</plugins>
489+
</build>
490+
</profile>
491+
</profiles>
492+
375493
<distributionManagement>
376494
<snapshotRepository>
377495
<id>ossrh</id>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package dev.openfeature.javasdk.integration;
2+
3+
import org.junit.platform.suite.api.ConfigurationParameter;
4+
import org.junit.platform.suite.api.IncludeEngines;
5+
import org.junit.platform.suite.api.SelectClasspathResource;
6+
import org.junit.platform.suite.api.Suite;
7+
8+
import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME;
9+
10+
@Suite
11+
@IncludeEngines("cucumber")
12+
@SelectClasspathResource("features")
13+
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty")
14+
public class RunCucumberTest {
15+
16+
}

0 commit comments

Comments
 (0)