Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Overview

Here are described the steps to connect TestRail with write karate integration tests.

Steps 

...

Project Setup

To prepare running karate tests you need to setup TestRail before by creation Test Suite and Sections 

  • Open Test Suites & Cases by testRail top menu and choose + Add Test Suite button

Image Removed

  • Set any name. (For our example it is "mod-orders")

Image Removed

  • Select your Suite and Crate Sections for test runs by + Add Section  and create default section (mod-orders for our case)

Image Removed

Image Removed

Project Setup

...

If you want to create module from scratch then create you maven module within folio-integration-tests folder like acquisitions (See also pom.xml file from folio-integration-tests/acquisitions/pom.xml for example)

  • Create JUnit test file folio-integration-tests/<YourProject>/src/test/java/org/folio/<YourTestFileName>.java
  • Project should have karate configuration file (See acquisitions/src/main/resources/karate-config.js)
  • Extend your Test with TestBase
  • Create constructor with TestModuleConfiguration and specify TEST_BASE_PATH (see FinanceApiTest for example)
Code Block
languagejava

...

public FinanceApiTest() {
	super(new 

...

TestIntegrationService(
	

...

new TestModuleConfiguration(TEST_BASE_PATH

...

)));
}

  • Add an test method with runFeatureTest where parameter is your karate feature file with test logic
Code Block
languagejava
@Test
void deleteOpenedOrderAndOrderLines() {
	runFeatureTest("delete-opened-order-and-lines.feature");
}

...

  • Add test method that will run your feature file like budget-expense-classes via runFeatureTest method that located in order to FINANCE_CONFIGURATION see budgetExpenseClasses
  • Add your suite Configuration see 50299221 section. For FinanceApiTest we use FINANCE_CONFIGURATION
  • Add two setup mehtods two setup methods into your test file like financeApiTestBeforeAll (to setup tenant, users and setup data for module run) and financeApiTestAfterAll (to destroy tenant and all related data for module run)
Note

...

finance-junit.feature and destroy-data.feature should contain logic to setup and

...

destroy data for tenant. (See examples acquisitions/src/main/resources/domain/mod-finance/finance-junit.feature and common/src/main/resources/common/destroy-data.feature)


Code Block
languagejavatitleSetup and Destroy methods
@BeforeAll
public void financeApiTestBeforeAll() {
	runFeature("classpath:domain/mod-finance/finance-junit.feature");
}

@AfterAll
public void financeApiTestAfterAll() {
	runFeature("classpath:common/destroy-data.feature");
}

Configuration

...

Code Block
languagejava
titleConfiguration example
public FinanceApiTest() { super(new TestRailIntegrationHelper(FINANCE_CONFIGURATION)); }

Finance Configuration use next data for configuration

  • FINANCE_TEST_BASE_PATH - "classpath:domain/mod-finance/features/"
  • FINANCE_TEST_SUITE_NAME - "mod-finance"
  • TEST_SUITE_ID - "111"
  • FINANCE_TEST_SECTION_ID - 1386

To get suite id and section id you can use postman collection Test Rail.postman_collection.json (Note: Update Authorization with basic Auth and your credentials)

Run

...

integration test

Code Block
languagebash
titleRun examples
mvn test -Dtest=FinanceApiTest -pl acquisitions -Dtestrail_url=https://foliotest.testrail.io -Dtestrail_userId=<your_user_id> -Dtestrail_pwd=<password> -Dtestrail_projectId=<test_rail_project_id>

Where you populate your out values like <your_user_id>, <password>, <test_rail_project_id> and instead of "-pl acquisitions" argument you should use your own project name.

Result of Jenkins after CI build

https://jenkins-aws.indexdata.com/job/FOLIO_Reference_Builds/job/folio-api-tests-karate/237/cucumber-html-reports/overview-features.html

Image Added