Forum Discussion

tdtruong's avatar
tdtruong
New Contributor
12 years ago

How to create a common log in test case for the others ?

Hi,
I start to use SoapUI last week. I need to create a prerequisited test case for log in, then other test cases will do some stuffs after. But I dont find option to make it possible, tried to run the test case for logging in first , but after that the other test cases require log in again, like it must include login step in every test case. Is there option to make the log in as a seperated test case to avoid repeating it ?

Beside that, I dont understand the way soapUI control cookie. I.e : after logging in, I use groovy to show cookie like

import com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport
import org.apache.http.impl.cookie.BasicClientCookie

def myClient = HttpClientSupport.getHttpClient()
def myStore = myClient.getCookieStore()
def cookieList = myStore.getCookies()
return "nbr---of---cookies : " + cookieList.size() + cookieList.toList()

but it returns nothing, I think it should contain session after logging , doesn it?

Thanks

3 Replies

  • tdtruong's avatar
    tdtruong
    New Contributor
    ok I figure out the option of 'Run Testcase' step. It works ok. But is there an option to make it faster running , like using groovy script or transfer property to avoid running log in again but transfer it's properties to other test cases after 1 time running only ?

    And please explain the cookie mechanism, why is it nothing after logging , no session ?

    Thanks much
  • Have you tried:

    - double click on the TestCase
    - in window that opens click the Options icon (wrench and screwdriver)
    - check "Maintain HTTP Session"

    Thanks,
    Michael Giller
    SmartBear Software
  • tdtruong's avatar
    tdtruong
    New Contributor
    yes, I tried but it didnt do the trick. Actually I use SoapUI 4.5.2, have 2 test cases (both checked "Maintain HTTP Session"):
    - test case 1 for step of logging in
    - test case 2 for step of getting the url only

    And test case 2 just get the page with a different sessionid and stay at log in form. If I put the step of 2 into 1, getting the url as logged user successfully. So I think that "Maintain HTTP Session" is used within the test case only, not cross test cases.

    Michael : can you explain the getCookieStore, why is it still nothing after logging in, I think it should contain the session ?
    As I need to test log in function, how can I create step of deleting session, and input some wrong value into existing parameters in the cookie ?

    Thanks