How to run test suite of features via testopt?

Hi,

I am running my test suite of feature files via testopt but the browser does not open and close at every scenario in the feature file. But I run test suite locally on Katalon studio, it works correctly.

Here is Test Listener file:

Thank you!
Loan

1 Like

Your “TestCaseListener” looks odd.

See the following “Test Listener/MyTestListner” which I created with default values:

import com.kms.katalon.core.annotation.AfterTestCase
import com.kms.katalon.core.annotation.BeforeTestCase
import com.kms.katalon.core.context.TestCaseContext

class NewTestListener {
	/**
	 * Executes before every test case starts.
	 * @param testCaseContext related information of the executed test case.
	 */
	@BeforeTestCase
	def sampleBeforeTestCase(TestCaseContext testCaseContext) {
		println testCaseContext.getTestCaseId()
		println testCaseContext.getTestCaseVariables()
	}

	/**
	 * Executes after every test case ends.
	 * @param testCaseContext related information of the executed test case.
	 */
	@AfterTestCase
	def sampleAfterTestCase(TestCaseContext testCaseContext) {
		println testCaseContext.getTestCaseId()
		println testCaseContext.getTestCaseStatus()
	}
}

Here @BeforeTestCase annotation and @AfterTestCase annotation are used. Katalon’s TestListener expects @BeforeTestCase, not @Before.

On the other hand, in your TestCaseListener I find @Before and @After annotation. How did you get it? I suppose you wrote these manually. JUnit4-like @Before annotations here looks odd to me.

1 Like