Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skip] Conditional skipping #288

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import static io.restassured.config.EncoderConfig.encoderConfig;

import io.cucumber.core.internal.com.fasterxml.jackson.core.JsonProcessingException;
import io.cucumber.java.Before;
import io.cucumber.java.Scenario;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.restassured.RestAssured;
import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.specification.RequestSpecification;
import org.junit.Assume;
import org.mifos.integrationtest.common.Utils;
import org.mifos.integrationtest.config.MojaloopConfig;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -100,4 +103,30 @@ public void mojaloopSetup() throws JsonProcessingException {
}
}

@Before("@ConditionalSkip")
public void beforeScenario(Scenario scenario) {
boolean shouldSkip = checkCondition();
if (!shouldSkip) {
Assume.assumeTrue("Skipping scenario: " + scenario.getName(), false);
}
}

private boolean checkCondition() {
RequestSpecification requestSpec = Utils.getDefaultSpec();
String endpoint = mojaloopConfig.mojaloopHubAccount;

String mojaloopBaseUrl = mojaloopConfig.mojaloopBaseurl;

try {
int statusCode = RestAssured.given(requestSpec).baseUri(mojaloopBaseUrl).when().get("/actuator").then().extract().statusCode();

return statusCode == 200;
} catch (Exception e) {

logger.error(e.getMessage());
return false;
}

}

}
10 changes: 5 additions & 5 deletions src/test/java/resources/mojaloop.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@gov @ext
Feature: Mojaloop test

@ConditionalSkip
Scenario: ML connector partial payee party lookup test
Given I am setting up Mojaloop
Given I have Fineract-Platform-TenantId for "payee"
Expand All @@ -17,7 +17,7 @@ Feature: Mojaloop test
# Then I will sleep for 5000 millisecond
Then I should be able to verify the callback for lookup
Then I can stop mock server

@ConditionalSkip
Scenario: ML connector partial payee quotation test
Given I am setting up Mojaloop
Given I have Fineract-Platform-TenantId for "payee"
Expand All @@ -34,7 +34,7 @@ Feature: Mojaloop test
# Then I will sleep for 5000 millisecond
Then I should be able to verify the callback for quotation
Then I can stop mock server

@ConditionalSkip
Scenario: ML connector partial payee transfer test
Given I am setting up Mojaloop
Given I have Fineract-Platform-TenantId for "payee"
Expand All @@ -55,7 +55,7 @@ Feature: Mojaloop test
# Then I will sleep for 5000 millisecond
Then I should be able to verify the callback for transfer
Then I can stop mock server

@ConditionalSkip
Scenario: Payer Fund Transfer Flow test
Given I am setting up Mojaloop
Given I have Fineract-Platform-TenantId for "payer"
Expand Down Expand Up @@ -100,7 +100,7 @@ Feature: Mojaloop test

Then I assert "payer" balance to be 11
Then I assert "payee" balance to be 11

@ConditionalSkip
Scenario: Bulk Transfer with Mojaloop
Given I am setting up Mojaloop
When I create and setup a "payer" with account balance of 12
Expand Down