{"id":25144463,"url":"https://github.com/openmf/ph-ee-integration-test","last_synced_at":"2025-04-28T11:20:37.546Z","repository":{"id":43635548,"uuid":"511471551","full_name":"openMF/ph-ee-integration-test","owner":"openMF","description":"An integration test microservice for payment hub","archived":false,"fork":false,"pushed_at":"2025-04-19T07:09:15.000Z","size":839,"stargazers_count":2,"open_issues_count":34,"forks_count":18,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-19T14:21:49.248Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openMF.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-07T09:51:27.000Z","updated_at":"2024-08-22T10:48:15.000Z","dependencies_parsed_at":"2023-12-18T15:07:26.790Z","dependency_job_id":"dde8c292-d129-49a3-94ac-2d765e5a25c1","html_url":"https://github.com/openMF/ph-ee-integration-test","commit_stats":null,"previous_names":["openmf/ph-ee-integration-test"],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openMF%2Fph-ee-integration-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openMF%2Fph-ee-integration-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openMF%2Fph-ee-integration-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openMF%2Fph-ee-integration-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openMF","download_url":"https://codeload.github.com/openMF/ph-ee-integration-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251302769,"owners_count":21567601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-08T19:46:24.801Z","updated_at":"2025-04-28T11:20:37.530Z","avatar_url":"https://github.com/openMF.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ph-ee-connector-integration-test\n\n![CUCUMBER](https://img.shields.io/badge/Cucumber-3DDC84?style=for-the-badge\u0026logo=cucumber\u0026logoColor=white)\n\u003cbr\u003e\nCucumber is a test writing framework which is used to achieve the idea of BDD(Behaviour Driven Development). To know more about BDD and why it is considered [read this article](https://www.tutorialspoint.com/behavior_driven_development/behavior_test_driven_development.htm).\n\n## Run test suite\n./gradlew cucumberCli\nOR\nhelm test \u003cExtended Chart of PH-EE-Engine\u003e\n\n## Three main components of cucumber\n1. Ghrekin feature file\n    Its is a human readable domain specific language, to deffine a behaviour.\n2. Step definition\n    Its the actual definition or implementation of each of the steps/ behaviour deffined in the feature file.\n3. Context configuration\n    Integration test can be spefcific to spring applicaiton, camel specific or any other environment. So cucmber can be configured with different context within which each of the step definition will be executed.\n\n## Dependency\nBelow are the required dependency to work in the spring and camel environment.\n```gradle\nimplementation 'io.cucumber:cucumber-java:7.8.1'\nimplementation 'io.cucumber:cucumber-spring:7.8.1'\ntestImplementation 'io.cucumber:cucumber-junit:7.8.1'\ntestImplementation 'org.apache.camel:camel-test:3.4.0'\ntestImplementation 'org.springframework.boot:spring-boot-starter-test:2.5.4'\n```\n\n## 1. Writing a feature file\nRefer the [official guide](https://cucumber.io/docs/gherkin/reference/) for any help wuth writing feature file. The extention of the feature file is `.feature`. Below is one of the sample feature file.\n```gherkin\nFeature: SLCB integration test\n  Scenario: Test the payload of the SLCB\n    Given I have a batchId: \"123-123-123\", requestId: \"3af-567-dfr\", purpose: \"integration test\"\n    And I mock transactionList with two transactions each of \"1\" value\n    And I can start camel context\n    When I call the buildPayload route\n    Then the exchange should have a variable with SLCB payload\n    And I can parse SLCB payload to DTO\n    And total transaction amount is 2\n    And total transaction count is 2, failed is 0 and completed is 0\n```\n\n## 2. Adding step definition\nThe step definition can be created in a simple plain java class. Inside the java class you can use all the design patterns specific to the context it is run in. So for example you want to use `@Autowire` for any bean then make sure you are using the `SpringBootTest` context and that bean is present in that context.\nEach of the step definition need to match with the phrase mentioned in the feature file with proper annotation. A sample step definition for the `Given I have a batchId: \"123-123-123\", requestId: \"3af-567-dfr\", purpose: \"integration test\"` expression is added below. Where {string} is the placeholder for the variable. To find more about variables data type [refer this](https://cucumber.io/docs/cucumber/step-definitions/?lang=java).\n```java\n@Given(\"I have a batchId: {string}, requestId: {string}, purpose: {string}\")\npublic void i_have_required_data(String batchId, String requestId, String purpose){\n    this.batchId = batchId;\n    this.requestId = requestId;\n    this.purpose = purpose;\n}\n```\n\n## 3. Configuring context for cucumber tests\nCucumber can be run in any context. And configuring this part totally depends on the scenario which we are testing. For configuring the context for spring applicaiton use the below annotation on default spring test class or create a new one.\n```java\n@SpringBootTest\n@CucumberContextConfiguration\n@ActiveProfiles(\"test\")\n@ContextConfiguration(classes = \u003cMain class for spring applciation\u003e, loader = SpringBootContextLoader.class)\n```\nThe `@CucumberContextConfiguration` is responsible for making sure that all the stepDefinitions are executed in this particular environment.\n\n---\nYay!! :boom: :boom:\n\u003cbr\u003e\nNow we can run respective feature file directly form the intellij.\n\u003cbr\u003e\n\u003cimg width=\"515\" alt=\"Screenshot 2022-10-26 at 6 58 19 PM\" src=\"https://user-images.githubusercontent.com/31315800/198042079-3964389a-df08-4c05-8951-52905c9fce04.png\"\u003e\n\n## Adding runner configuration\nBelow java class will make sure to run cucumber test using JUnit test command.\nWhere the `glue` property is for defining the package which contains the step definitions, `feature` refers to the path where feature file is located and `plugin` is for providing different plugin configuration supported by cucumber.\n```java\n@RunWith(Cucumber.class)\n@CucumberOptions(\n        features = {\"src/test/java/resources\"},\n        glue = {\"org.mifos.integrationtest.cucumber\"},\n        plugin = {\n            \"html:cucumber-report\",\n            \"json:cucumber.json\",\n            \"pretty\",\n            \"html:build/cucumber-report.html\",\n            \"json:build/cucumber-report.json\"\n## Adding gradle configuration\nAdding gradle configuration will allow us to run all the cucumber feature file at using using a CLI.\n\n```gradle\nconfigurations {\n    cucumberRuntime {\n        extendsFrom testImplementation\n    }\n}\n\ntask cucumberCli() {\n    dependsOn assemble, testClasses\n    doLast {\n        javaexec {\n            main = \"io.cucumber.core.cli.Main\"\n            classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output\n            args = [\n                    '--plugin', 'pretty',\n                    '--plugin', 'html:target/cucumber-report.html',\n                    '--glue', 'org.mifos.connector.slcb.cucumber',\n                    'src/test/java/resources']\n        }\n)\npublic class TestRunner {\n}\n```\nAdding below configuration will allow us to wire the CLI arguments be passed in the actual runner configuration while running the cucumber test using JUnit.\n```groovy\ntest {\n    systemProperty \"cucumber.filter.tags\", System.getProperty(\"cucumber.filter.tags\")\n}\n```\n## Running an integration test\nUse below command to execute the integration test.\n```shell\n./gradlew test -Dcucumber.filter.tags=\"\u003ccucumber tag\u003e\"\n```\nWhere `\u003ccucumber tag\u003e` has to be replaced with valid tag, for example if you are willing to run test cases related to g2p scenario then pass the tag `@gov`. If `-Dcucumber.filter.tags` flag is omitted then all the test cases would be triggered independent of the tag.\n```shell\n* Try:\n\u003e Run with --stacktrace option to get the stack trace.\n\u003e Run with --debug option to get more log output.\n\u003e Run with --scan to get full insights.\n```\n\n# Checkstyle\nUse below command to execute the checkstyle test.\n```shell\n./gradlew checkstyleMain\n```\n\n## Spotless\nUse below command to execute the spotless apply.\n```shell\n./gradlew spotlessApply\n```\n\n## FAQs\n1. How to make step def reusable?\n2. Order of execution of feature/steps?\n3. Calling a scenario from another feature?\n4. How cucumber picks feature file? How to configure the location of feature file?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenmf%2Fph-ee-integration-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenmf%2Fph-ee-integration-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenmf%2Fph-ee-integration-test/lists"}