Data Binding - Excel test data row has to be executed based on the Y or N flag

I am doing the excel data-driven testing using the Data Binding Feature

Now I have a requirement to add a flag named Execute Column, with value Y or N

Based on this value i.e. Y or N, the test data row has to be executed.

Any help would be greatly appreciated. :dizzy_face:

image

1 Like

@discover.selenium

How about adding the statement

if(execute != 'Y') {
return;
}

At the beginning of your test case. When the execute variable is binded, it will be checked and the inner return will skip the current test case.

1 Like

Thanks @ThanhTo appreciate your help.

Your logic helped me to skip the excel row, where Execute Column, with value N

But in the html report, the testcase is considered as pass, for Execute Column, with value N .

Is there a way to mark it as skipped in html report?

@discover.selenium i think it is time you can (re) raise a feature request, sort of ‘markTestAsSkipped’
We had a lot of discussions regarding possible workarounds on skiping a testcase execution, but having such status into the final report was never considered.
Cc @Russ_Thomas @ThanhTo @devalex88 @duyluong

2 Likes

Yes, I remember it. Not sure if it was ever picked up by the devs though.

1 Like

@Russ_Thomas @bionel @discover.selenium

Just some precautions, when the official 7.8 is out, then you can achieve this by following this (sort of) tutorial. Right now, the beta version doesn’t yet have the feature of adding the Skipped status into HTML report. Hopefully it’ll get you hyped up for it. :stuck_out_tongue:

Katalon 7.8 official version supports Skipped status in final report (viewed in katalon, html, pdf, junit, etc).

Tutorial

Prerequisites:

  • Katalon 7.8 (official version - not the Beta version).

Objectives:

  • Skip some test case executions based on some data-binded values.
  • Have the Skipped status of skipped test executions available in reports.

Goals:

  • To demonstrate that you can do this with the upcoming official version.
  • Serve as a guide for future users.

Steps:

1/ Create test data, here I am using Internal Test Data, but Excel or other types of Data would work as well. We want to execute only rows with execute value of Y, and skip rows with value N.

2/ Prepare the test case with test case variables.

3/ Add test case to test suite and bind data to test case.

4/ Create a Test Listener, using the annotation @BeforeTestDataBindToTestCase

class MyTestListener {
	@BeforeTestDataBindToTestCase
	void beforeTestDataBindToTestCase(TestCaseContext tcContext, TestSuiteContext tsContext, Map variableBindings) {
		String execute = variableBindings['execute'];
		if(execute == 'N') {
			tcContext.skipThisTestCase()
		}
	}
}

The code above is simple, the method annotated with @BeforeTestDataBindToTestCase will be given a TestCaseContext, TestSuiteContext and a populated map of data-binded test case variables. It checks the map for the current value of execute value, and then call TestCaseContext.skipThisTestCase which skips the test case and marks the test as skipped in the final report.

5/ Execute the test suite and view the reports.

In Katalon:

In HTML report:

In PDF report:

3 Likes

@ThanhTo as you probably recall, I don’t do any data driven testing, but I could follow that tutorial with ease. Good job!

1 Like

Thank you @ThanhTo @Russ_Thomas @bionel