How to use Junit/Test NG annotations in my Katalon Scripts?

Hi,

I tried to script my tests with Junit/Test NG annotations but i failed.I want to run my single script for multiple test data like we do with @DataProvider annotation but i failed.

When i try to use any of the Junit/Test NG annotations like @Test.I see warning message as “The Test Case has no step to run.Please add some steps before execution.”

Below is my sample script.
@Test
public static void Login(){
try{
WebUI.openBrowser(url)
WebUI.waitForElementClickable(findTestObject(‘Object Repository/Page_Log In - Catalyst Insight/Login_button’), 10)
WebUI.setText(findTestObject(‘Object Repository/Page_Log In /Login_username’),username, FailureHandling.STOP_ON_FAILURE)
WebUI.setText(findTestObject(‘Object Repository/Page_Log In /Login_Password’),password, FailureHandling.STOP_ON_FAILURE)
WebUI.click(findTestObject(‘Object Repository/Page_Log In /Login_button’), FailureHandling.STOP_ON_FAILURE)
//WebUiBuiltInKeywords.waitForElementPresent(findTestObject(‘Object Repository/Page_Select A Site /CaseList_Createsite’), 8)
WebUiBuiltInKeywords.verifyElementPresent(findTestObject(‘Object Repository/Page_Select A Site/CaseList_Createsite’), 10)
}
catch(Exception a){
System.out.println("exception occured "+a.getMessage())
}

WebUI.closeBrowser()}

 

Can you please guide me? I might be missing something here.

Thanks in advance.

I found the steps here for multiple test execution here https://docs.katalon.com/display/KD/Execute+a+test+suite#Executeatestsuite-DataforTestExecution.Now its working fine.

But still not able to run my tests as JUnit/TestNG tests

Hi there,

In Katalon Studio script, you need to add a step or call a method. Based from your script, you need to call Login() function as a step, e.g:

Login()

static void Login() {

try {

WebUI.openBrowser(url)

WebUI.waitForElementClickable(findTestObject('Object Repository/Page_Log In \u2013 Catalyst Insight/Login_button'), 10)

WebUI.setText(findTestObject('Object Repository/Page_Log In /Login_username'), Username, FailureHandling.STOP_ON_FAILURE)

WebUI.setText(findTestObject('Object Repository/Page_Log In /Login_Password'), Password, FailureHandling.STOP_ON_FAILURE)

WebUI.click(findTestObject('Object Repository/Page_Log In /Login_button'), FailureHandling.STOP_ON_FAILURE)

//WebUiBuiltInKeywords.waitForElementPresent(findTestObject('Object Repository/Page_Select A Site /CaseList_Createsite'), 8)

WebUiBuiltInKeywords.verifyElementPresent(findTestObject('Object Repository/Page_Select A Site/CaseList_Createsite'),
10)
}
catch (Exception a) {
System.out.println('exception occured ' + a.getMessage())
}

WebUI.closeBrowser()
}