Versions Compared

Key

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

Overview

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

...

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 Modified

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

Image Modified

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

Image Modified

Project Setup

  • Copy all related files from package org.folio.testrail of acquisitions to your project path
  • Create jUnit test file and extend from AbstractTestRailIntegrationTest like FinanceApiTestOrdersApiTest


    Code Block
    languagejava
    titleFinanceApiTest Example
    public class OrdersApiTest extends AbstractTestRailIntegrationTest {
    
    // default module settings
    private static final String TEST_BASE_PATH = "classpath:domain/mod-orders/features/";
    private static final String TEST_SUITE_NAME = "mod-orders";
    private static final long TEST_SECTION_ID = 3337L;
    private static final long TEST_SUITE_ID = 159L;
    
    public OrdersApiTest() {
    	super(new TestRailIntegrationService(
    		new TestModuleConfiguration(TEST_BASE_PATH, TEST_SUITE_NAME, TEST_SUITE_ID, TEST_SECTION_ID)));
    }
    
    @Test
    void deleteOpenedOrderAndOrderLines() {
    	runFeatureTest("delete-opened-order-and-lines.feature");
    }


  • Add your suite Configuration see 50299221 section. For OrdersApiTest we use TEST_SUITE_ID = 159 and TEST_SECTION_ID = 3337
  • Add constructor with your own configuration see FinanceApiTestOrdersApiTest
  • 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

    delete-opened-order-and-lines.feature via runFeatureTest method

  • Add two setup mehtods into your test file like financeApiTestBeforeAll ordersApiTestBeforeAll (to setup tenant, users and setup data for module run) and financeApiTestAfterAll andordersApiTestAfterAll (to destroy tenant and all related data for module run)


    Note: financeorders-junit.feature and feature and destroy-data.feature should contain logic to setup and destory destroy data for tenant.
Code Block
languagejava
titleSetup and Destroy methods
@BeforeAll
public void financeApiTestBeforeAllordersApiTestBeforeAll() {
	runFeature("classpath:domain/mod-financeorders/financeorders-junit.feature");
}

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

...

Code Block
languagejava
titleConfiguration example
public FinanceApiTestOrdersApiTest() { 
	super(new TestRailIntegrationHelper(FINANCE_CONFIGURATIONTestRailIntegrationService(new TestModuleConfiguration(TEST_BASE_PATH, TEST_SUITE_NAME, TEST_SUITE_ID, TEST_SECTION_ID))); 
}

Finance Orders Configuration use next data for configuration

  • FINANCE_TEST_BASE_PATH - "classpath:domain/mod-finance/features/"
  • FINANCE_TEST_SUITE_NAME - "mod-finance"
  • TEST_SUITE_ID - "111159"
  • FINANCE_TEST_SECTION_ID -  13863337

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)

...

Code Block
languagebash
titleRun examples
mvn test -Dtest=FinanceApiTestOrdersApiTest -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.


Result of TestRail Run

If Tests has passed successfully then you should see result "Test Runs & Results" menu section

Image Added

Image Added