This is a migrated thread and some comments may be shown as answers.

Error Handling

2 Answers 35 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Reddy
Top achievements
Rank 1
Reddy asked on 21 May 2012, 02:44 PM
I have this code written as a Script Step.
I am extracting the value "BC_PolEffectiveDate" from a web application and comparing it to a value "EffectiveDate" in the database.

 

 

<FONT color=#0000ff size=2 face="courier new">
<P>If </FONT><FONT size=2 face="courier new">Data(</FONT><FONT 
color=#800000 size=2 face="courier new">"EffectiveDate"</FONT><FONT size=2 
face="courier new">).ToString() = BC_PolEffectiveDate </FONT>Then </P>
<P> <FONT size=2 face="courier new">Log.WriteLine(</FONT><FONT 
color=#800000 size=2 face="courier new">"AQS Policy Effective Date matches 
Billing Center Policy Effective Date"</FONT>) </P>
<P> <FONT color=#008000 size=2 face="courier new">Else</P>
<P> Log.WriteLine("AQS Policy Effective Date does not match Billing Center 
Policy Effective Date")</P></FONT><FONT color=#0000ff size=2 face="courier new">
<P>End If</P></FONT>

I can see from the log when these two values do not match but when i run the script on a schedule, Test Studio returns just a pass or fail info and the test passes either by going into the IF or ELSE condition. I need to fail the test when the script goes into the ELSE condition. How can i handle that? Is there a custom code that i can use to change the status of the test when i encounter certain conditions?

 

2 Answers, 1 is accepted

Sort by
0
Reddy
Top achievements
Rank 1
answered on 21 May 2012, 03:58 PM
I was able to use the Assert.IsTrue for this. My test is working as required.

Thank you,
Nithin
0
Accepted
Anthony
Telerik team
answered on 21 May 2012, 04:29 PM
Hello Nithin,

I'm glad you found a solution. See here for an alternative approach to failing the test based on a condition in a coded step.

All the best,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Reddy
Top achievements
Rank 1
Answers by
Reddy
Top achievements
Rank 1
Anthony
Telerik team
Share this question
or