Skip to content

Commit

Permalink
test: Update gherkin test sub module (#1236)
Browse files Browse the repository at this point in the history
Signed-off-by: Bernd Warmuth <[email protected]>
  • Loading branch information
warber authored Dec 5, 2024
1 parent 409fd04 commit 473be86
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 24 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "test-harness"]
path = test-harness
url = https://github.com/open-feature/test-harness
[submodule "spec"]
path = spec
url = https://github.com/open-feature/spec/
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ If you're adding tests to cover something in the spec, use the `@Specification`

## End-to-End Tests

The continuous integration runs a set of [gherkin e2e tests](https://github.com/open-feature/test-harness/blob/main/features/evaluation.feature) using `InMemoryProvider`.
The continuous integration runs a set of [gherkin e2e tests](https://github.com/open-feature/spec/blob/main/specification/assets/gherkin/evaluation.feature) using `InMemoryProvider`.

to run alone:
```
Expand Down
7 changes: 3 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -554,22 +554,21 @@
<argument>submodule</argument>
<argument>update</argument>
<argument>--init</argument>
<argument>test-harness</argument>
<argument>spec</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>copy-gherkin-tests</id>
<id>copy-evaluation-gherkin-tests</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<!-- copy the feature spec we want to test into resources so them can be easily loaded -->
<!-- run: cp test-harness/features/evaluation.feature src/test/resources/features/ -->
<executable>cp</executable>
<arguments>
<argument>test-harness/features/evaluation.feature</argument>
<argument>spec/specification/assets/gherkin/evaluation.feature</argument>
<argument>src/test/resources/features/</argument>
</arguments>
</configuration>
Expand Down
1 change: 1 addition & 0 deletions spec
Submodule spec added at d4a9a9
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
import org.junit.platform.suite.api.SelectClasspathResource;
import org.junit.platform.suite.api.Suite;

import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME;
import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME;

@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("features")
@SelectClasspathResource("features/evaluation.feature")
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty")
public class RunCucumberTest {

@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "dev.openfeature.sdk.e2e.evaluation")
public class EvaluationTest {

}



Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.openfeature.sdk.e2e;
package dev.openfeature.sdk.e2e.evaluation;

import dev.openfeature.sdk.Value;
import dev.openfeature.sdk.EvaluationContext;
Expand Down Expand Up @@ -52,7 +52,7 @@ public class StepDefinitions {

@SneakyThrows
@BeforeAll()
@Given("an openfeature client is registered with cache disabled")
@Given("a provider is registered")
public static void setup() {
Map<String, Flag<?>> flags = buildFlags();
InMemoryProvider provider = new InMemoryProvider(flags);
Expand All @@ -67,7 +67,7 @@ public static void setup() {
// boolean value
@When("a boolean flag with key {string} is evaluated with default value {string}")
public void a_boolean_flag_with_key_boolean_flag_is_evaluated_with_default_value_false(String flagKey,
String defaultValue) {
String defaultValue) {
this.booleanFlagValue = client.getBooleanValue(flagKey, Boolean.valueOf(defaultValue));
}

Expand Down Expand Up @@ -117,7 +117,7 @@ public void an_object_flag_with_key_is_evaluated_with_a_null_default_value(Strin

@Then("the resolved object value should be contain fields {string}, {string}, and {string}, with values {string}, {string} and {int}, respectively")
public void the_resolved_object_value_should_be_contain_fields_and_with_values_and_respectively(String boolField,
String stringField, String numberField, String boolValue, String stringValue, int numberValue) {
String stringField, String numberField, String boolValue, String stringValue, int numberValue) {
Structure structure = this.objectFlagValue.asStructure();

assertEquals(Boolean.valueOf(boolValue), structure.asMap().get(boolField).asBoolean());
Expand All @@ -132,7 +132,7 @@ public void the_resolved_object_value_should_be_contain_fields_and_with_values_a
// boolean details
@When("a boolean flag with key {string} is evaluated with details and default value {string}")
public void a_boolean_flag_with_key_is_evaluated_with_details_and_default_value(String flagKey,
String defaultValue) {
String defaultValue) {
this.booleanFlagDetails = client.getBooleanDetails(flagKey, Boolean.valueOf(defaultValue));
}

Expand All @@ -148,13 +148,13 @@ public void the_resolved_boolean_value_should_be_the_variant_should_be_and_the_r
// string details
@When("a string flag with key {string} is evaluated with details and default value {string}")
public void a_string_flag_with_key_is_evaluated_with_details_and_default_value(String flagKey,
String defaultValue) {
String defaultValue) {
this.stringFlagDetails = client.getStringDetails(flagKey, defaultValue);
}

@Then("the resolved string details value should be {string}, the variant should be {string}, and the reason should be {string}")
public void the_resolved_string_value_should_be_the_variant_should_be_and_the_reason_should_be(String expectedValue,
String expectedVariant, String expectedReason) {
String expectedVariant, String expectedReason) {
assertEquals(expectedValue, this.stringFlagDetails.getValue());
assertEquals(expectedVariant, this.stringFlagDetails.getVariant());
assertEquals(expectedReason, this.stringFlagDetails.getReason());
Expand All @@ -168,7 +168,7 @@ public void an_integer_flag_with_key_is_evaluated_with_details_and_default_value

@Then("the resolved integer details value should be {int}, the variant should be {string}, and the reason should be {string}")
public void the_resolved_integer_value_should_be_the_variant_should_be_and_the_reason_should_be(int expectedValue,
String expectedVariant, String expectedReason) {
String expectedVariant, String expectedReason) {
assertEquals(expectedValue, this.intFlagDetails.getValue());
assertEquals(expectedVariant, this.intFlagDetails.getVariant());
assertEquals(expectedReason, this.intFlagDetails.getReason());
Expand All @@ -182,7 +182,7 @@ public void a_float_flag_with_key_is_evaluated_with_details_and_default_value(St

@Then("the resolved float details value should be {double}, the variant should be {string}, and the reason should be {string}")
public void the_resolved_float_value_should_be_the_variant_should_be_and_the_reason_should_be(double expectedValue,
String expectedVariant, String expectedReason) {
String expectedVariant, String expectedReason) {
assertEquals(expectedValue, this.doubleFlagDetails.getValue());
assertEquals(expectedVariant, this.doubleFlagDetails.getVariant());
assertEquals(expectedReason, this.doubleFlagDetails.getReason());
Expand Down Expand Up @@ -217,7 +217,7 @@ public void the_variant_should_be_and_the_reason_should_be(String expectedVarian

@When("context contains keys {string}, {string}, {string}, {string} with values {string}, {string}, {int}, {string}")
public void context_contains_keys_with_values(String field1, String field2, String field3, String field4,
String value1, String value2, Integer value3, String value4) {
String value1, String value2, Integer value3, String value4) {
Map<String, Value> attributes = new HashMap<>();
attributes.put(field1, new Value(value1));
attributes.put(field2, new Value(value2));
Expand Down Expand Up @@ -253,7 +253,7 @@ public void the_resolved_flag_value_is_when_the_context_is_empty(String expected
// not found
@When("a non-existent string flag with key {string} is evaluated with details and a default value {string}")
public void a_non_existent_string_flag_with_key_is_evaluated_with_details_and_a_default_value(String flagKey,
String defaultValue) {
String defaultValue) {
notFoundFlagKey = flagKey;
notFoundDefaultValue = defaultValue;
notFoundDetails = client.getStringDetails(notFoundFlagKey, notFoundDefaultValue);
Expand All @@ -273,7 +273,7 @@ public void the_reason_should_indicate_an_error_and_the_error_code_should_be_fla
// type mismatch
@When("a string flag with key {string} is evaluated as an integer, with details and a default value {int}")
public void a_string_flag_with_key_is_evaluated_as_an_integer_with_details_and_a_default_value(String flagKey,
int defaultValue) {
int defaultValue) {
typeErrorFlagKey = flagKey;
typeErrorDefaultValue = defaultValue;
typeErrorDetails = client.getIntegerDetails(typeErrorFlagKey, typeErrorDefaultValue);
Expand Down
1 change: 0 additions & 1 deletion test-harness
Submodule test-harness deleted from 2d4c63

0 comments on commit 473be86

Please sign in to comment.