How to continue the test if one of the method fails | Selenium Forum
P
Padmaja Challa Posted on 14/02/2023

Hi All,

 

 

   Below is my Code. if my test fails >MobileWealthPage.insightProperties(testDataMap, 21, 40); 

 

How to proceed running the remaining methods?

MobileWealthPage.insightProperties(testDataMap, 41, 60);

MobileWealthPage.insightProperties(testDataMap, 61, 80);

MobileWealthPage.insightProperties(testDataMap, 81, 92);

 

 

 

 

 

public class MobileWealthChannelPageTests extends BaseTest {

 

@Test(dataProvider = "mobilewealthtestdata", priority = 1)

public void MobileWealthTest(String key, Map<String, List<String>> testDataMap) throws InterruptedException {

MobileWealthChannelPage MobileWealthPage = new MobileWealthChannelPage(getDriver());

MobileWealthPage.channelInsights(testDataMap);

MobileWealthPage.insightProperties(testDataMap, 1, 20);

MobileWealthPage.insightProperties(testDataMap, 21, 40);

MobileWealthPage.insightProperties(testDataMap, 41, 60);

MobileWealthPage.insightProperties(testDataMap, 61, 80);

MobileWealthPage.insightProperties(testDataMap, 81, 92);

 

}

 

// Data Providers

 

@DataProvider(name = "mobilewealthtestdata")

public Object[][] mobilewealthTestData() throws Exception {

Map<String, List<String>> testDataMap = ExcelUtils.getTestDataMap(testDataFile, "MobileWealthPage");

Object[][] testData = new Object[1][2];

testData[0][0] = "testData";

testData[0][1] = testDataMap;

return testData;

}

 

}


D
Devesh Anand Replied on 02/03/2023

Hi, If your test fails or if you intentionally fail the test - and you want to continue to run the furthur test - then you need to Soft Assertion...


P
Padmaja Challa Replied on 08/03/2023

Hi Devesh,

 

  Thank you for the Reply. I just added (sofassert.Assertall) at the end of the Test method. still same problem.

Actually, all of these tests are running from the object of the same class. 

I tried adding the parameter for the test method(alwaysrun=true) - no use

I tried trycatch block for each test case under this method- No use.

 

If any solution from your end and shared , that will be apreciated

TYIA