This question is locked. New answers and comments are not allowed.
I know that this catches the assert and continue and log it, but I want to log the line it failed on in the code like how it does without the try catch?
try
{
//Verify grid view is empty
Assert.IsFalse(whatever is true);
}
catch (Exception e)
{
Log.WriteLine(e.Message);
}
6 Answers, 1 is accepted
0
Hello Cher,
Without using try..catch block the test will fail.
Why you don't want to use that block?
Please elaborate a bit more on your scenario so we can try to find you a workaround.
Looking forward to hearing from you.
Regards,
Boyan Boev
Telerik
Without using try..catch block the test will fail.
Why you don't want to use that block?
Please elaborate a bit more on your scenario so we can try to find you a workaround.
Looking forward to hearing from you.
Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings
0
CVue
Top achievements
Rank 1
answered on 13 May 2015, 02:00 PM
reason why is, sure the code above works but doesn't tell you in the log is what line it failed on. I would like to go back to the log and verify where it failed.
0
CVue
Top achievements
Rank 1
answered on 13 May 2015, 02:01 PM
I want to know where in the code did it failed like what line. Since it fails but continue to go through the test, it would be nice if it failed but show you the line where it failed as well in the log.
0
Hello Cher,
You can modify the code like this:
This will write into the log the entire StackTrace.
Let me know if this helps.
Regards,
Boyan Boev
Telerik
You can modify the code like this:
try
{
Assert.AreEqual(
Assert.IsFalse(whatever is true););
}
catch
(Exception e)
{
Log.WriteLine(e.StackTrace.ToString());
}
This will write into the log the entire StackTrace.
Let me know if this helps.
Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings
0
CVue
Top achievements
Rank 1
answered on 18 May 2015, 01:52 PM
Yes, that will tell me where in the code it failed, but not what step/line it failed on.
0
Hi Cher,
You can also add the description of the step to be outputted:
You should add assembly reference to System.Runtime.Serialization.
Hope this helps.
Regards,
Boyan Boev
Telerik
You can also add the description of the step to be outputted:
try
{
Assert.AreEqual(
true
, Pages.PageTitle.input.IsVisible());
}
catch
(Exception e)
{
Log.WriteLine(
"The failed step is: "
+ ExecutionContext.CurrentStep.Description.ToString()+ Environment.NewLine + e.StackTrace.ToString());
}
You should add assembly reference to System.Runtime.Serialization.
Hope this helps.
Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings