Best Practice to handle Login-Testcase in a Test suite

Hey there,
im trying to find a smart way to handle a login testcase as part of a bigger test-suite with minimal code-duplication.

Issue: all my test-cases require a login at the start, so instead of doing that in every single test-case i do this in the test-suite script with

@SetupTestCase(skipped = false) // Please change skipped to be false to activate this method.def setupTestCase() {WebUI.navigateToUrl('redactedURL.com')	//LoginCustomKeywords.'test.key.login'('timo.becker@capitol.test', '123456') 	

Now i have a login validation test-case which looks something like this and should not execute the login as part of the setup

//Login with no DataCustomKeywords.'test.key.login'('', '')WebUI.verifyElementPresent(findTestObject('General/text_form_error'), 1)//Login with invalid EmailCustomKeywords.'test.key.login'('timo.becker@capitol', '123456')WebUI.verifyElementPresent(findTestObject('General/text_form_error'), 1)//Login with invalid PasswordCustomKeywords.'test.key.login'('timo.becker@capitol-versicherung.test', '654321')WebUI.verifyElementPresent(findTestObject('General/text_form_error'), 1)//Login with deactivated UserCustomKeywords.'test.key.login'('ulf.steinke@test.test', '123456')WebUI.verifyElementPresent(findTestObject('General/text_form_error'), 1)//Login with valid DataCustomKeywords.'test.key.login'('timo.becker@capitol-versicherung.test', '123456')WebUI.verifyElementNotPresent(findTestObject('General/text_form_error'), 1)WS.sendRequestAndVerify(findTestObject('api/login'))

What would be a smart way to approach this?

1 Like

hello,
does your application support logout? - that can be solution for login TC
other way would be to open incognito window only for this one TC (i think i saw guide for that somewhere around here)

yeah, that was the best solution i could think of so far, just start the login testcase by doing a logout at the start.