0

The scenario is like i will fetch four data from open api end points from a json array for the first threenter code heree output. Then i kept the data in four arraylist, account no, com amount, revenue amount, mark up realized amount. Till this it works fine. Now i have to take the first index data from each of the list and use it in a test method. In this whay i would take the secound index, third indexx data from array list and use it in the sme test method. The test method will go the ui and vaidate. I have right now used a loop which executes this test method three times by taking data three times from the arraylist. Is there a different way where i can avoid the loop in test method and the test method will execute three times by taking the each index value from the arraylist.

@Test(dependsOnMethods = "getTransactionRecordDetailsForSpecificAccountNumberByDateRange")

public void verifyTransactionDetailsFromOpenAPIOnSFObject() throws InterruptedException, AWTException {enter code here

    
    for (int i = 0; i < 3; i++) {
        
        launchApp();
        homepage = new HomePage();
        companyaccountpage = new CompanyAccountPage();
        homepage.navigateToCompanyAccountDetailsPage(li_AcctNo.get(i));
        companyaccountpage.navigateToTransactionTableDetails();
        Assert.assertEquals(companyaccountpage.getValueOfTotalComissionAmountFromTransactionTable(actual_tsDate),
                li_comAmt.get(i));
        Assert.assertEquals(companyaccountpage.getValueOfTotalMarkUpRealizedAmountTransactionTable(actual_tsDate),
                li_markupAmt.get(i));
        Assert.assertEquals(companyaccountpage.getValueOfTotalRevenueAmountFromTransactionTable(actual_tsDate),
                li_revenueAmt.get(i));`enter code here`
        fd.quit();
2
  • 1
    Have a look at JUnit parametrized tests (depending on whether you use JUnit 4 or 5). Commented Apr 30, 2021 at 22:40
  • Does this answer your question? Junit create tests based on dynamic data Commented May 3, 2021 at 11:38

1 Answer 1

0

Perhaps three different test cases would be another way to do things logically too since you're testing for different details. If you're worried about code duplication, then you can make a separate function for the loop logic.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.