How to fail a test cases

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

How to fail a test cases

tulsi.tester
Hi,
I am doing my login functionality. For the first fours sets of data, the validation error messages are different. My question is how to fail a test case at the last, if one of the validation message is not the intended one.My test case should run till all the sets of data provided. Please provide any pseudo code or process to achieve it
Reply | Threaded
Open this post in threaded view
|

Re: How to fail a test cases

softwaretestingforum
Administrator
You could use -

Assert.fail("message")

to inject failure in your test. Does it answer your question?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: How to fail a test cases

tulsi.tester
I think you misunderstand my question. Let me explain clearly here. I need to validate the validation error messages of a login functionality of a website. The scenarios are as follows
1.Uname = empty  pwd=empty   ==> 1st validation message
2.Uname =emtpy  pwd = invalid   ==> 2nd validation message
3. Uname = invalid  pwd = empty  ==> 3rd validation message
4. Uname = Invalid  pwd = invalid  ==> 4th validation message
5. Uname = valid   pwd = valid   ==> successfull login.

I need to check all these validation messages are appearing correct as intended. Suppose if 2nd validation message is not correct it should continue the test case til end. After the completion of the test it should show the status as fail(Eventhought the validation message for the 2nd set of data is incorrect).

I heard about the concept called verificationErrors,etc

Could you help me that.
Reply | Threaded
Open this post in threaded view
|

Re: How to fail a test cases

softwaretestingforum
Administrator
Yup, custom verification would be the way to go.
This post might help - http://www.seleniumtests.com/2011/05/verification-of-application-element.html
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: How to fail a test cases

tulsi.tester
Thank you tarun. I have started trying to implement the customVerification methods. I will let you know if any issues.
Reply | Threaded
Open this post in threaded view
|

Re: How to fail a test cases

Illusion0Reality
In reply to this post by tulsi.tester
Late reply !

selenium.isElementPresent - seems the best way!

I wrote a function like this (though not related to verify a text present in a page) :

// this the case to jump to this below username related code.
case username:

//Verifies whether the field with id=user_123 existis using the ---- verifyExistence()

if (av.verifyExistence(("id=user_123"),      pagename,"","",excelrc)) {


//If exists, then Enter data  which is passed via this array fnamearr[ ]
driver.findElement(By.id(UserName)).sendKeys(fnamearr[rc+1]);


//once succeeded, then write the success result to XLS using Apache POI

av.writePOI(passflag,pagename,fnamearr[rc],fnamearr[rc+1],excelrc,"c:\\resultsall.xls",passdescription); }
break;


In the verifyExistence() method, I do more things. I will verify enabled disabled etc.

If disabled, I write discrepancy into XLS as Fail - Anyway, the test run will continue.

If want to verify the text is present in an edit box, I would write a reusable function which takes 2 parameters; One is id/name of the edit box. Second one is the text to be present.



Reply | Threaded
Open this post in threaded view
|

Re: How to fail a test cases

tulsi.tester
In reply to this post by tulsi.tester
Hi Tarun,

Do i need to call customVerification() method only once in the class. When and where I need to call this method. Could you give me example.
Reply | Threaded
Open this post in threaded view
|

Re: How to fail a test cases

softwaretestingforum
Administrator
You should call it whenever you want to make any assertion. Look for method - verifyObjectDefinitions in the example I posted earlier.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: How to fail a test cases

tulsi.tester
Hi tarun,

I am calling on method from another class to present class. If I use checkForVerifcationErrors() in the present class it is not failing even though there are errors in the another class. So where I need to exactly call this method. Please let me know.
Reply | Threaded
Open this post in threaded view
|

Re: How to fail a test cases

softwaretestingforum
Administrator
Both verificationMethod and checkForVerifcationErrors() should be in same method.
Can you post your code?
~ seleniumtests.com