Best Practice: Conditional Login Step

Hi there,

I am new to TestProject, and trying to figure out the best way to set up tests for a web app. One question is around the login. I know I can create a test for the login, and then add that test as a sub-test to other tests, but then if I want to bundle a whole lot of tests in a scheduled job, it will try to log in over and over again, which is not very efficient.

So in some cases I want to test individual tests, which means I need it to log in, but then other times I want to run multiple tests which means I don’t want it to log in each time. What is the best way to handle this?

Can I perhaps do some sort of check to see if I am already logged in, and then only carry out the login step of not already logged in?

Thanks
David

Hi @david.bann I had the exact scenario to automate. We are testing a web streaming platform where each test case needed to be run separately as well as part of a job. Obviously without logging in nothings possible. So exactly as you said we wrote a condition to execute the Login sub test which was part of every test. For us, we checked if the user is already logged in by getting the username on one of the views and then if the username is valid then we assume that the user has logged in and we skip the test. Maybe you can also do something similar.

PS: We used get text add on to check if the username and store it to a variable, then for the login subtest, in the conditions, we check if the username is as expected or not.

2 Likes

Thanks - I suspected I might need top do something like this but just wanted to be sure there was not a better way - I appreciate the response :slight_smile: