Command to stop iteration
Command to stop iteration
Hello,
I have my test cases set to "continue with iteration" because generally the show must go on. I do have one case within the first code module where if it does not find the correct page, than I want the current iteration to end and the next iteration to start.
Is there a programmatic way to ask the iteration to stop in one particular instance?
I have an aside question as well. When I manually stop a run it doesn't bring up the report "so far" I find this annoying. I am in debug mode so I often don't need the entire test case to complete but I'd often like to view the log. Is this possible?
Thanks
Sierra
I have my test cases set to "continue with iteration" because generally the show must go on. I do have one case within the first code module where if it does not find the correct page, than I want the current iteration to end and the next iteration to start.
Is there a programmatic way to ask the iteration to stop in one particular instance?
I have an aside question as well. When I manually stop a run it doesn't bring up the report "so far" I find this annoying. I am in debug mode so I often don't need the entire test case to complete but I'd often like to view the log. Is this possible?
Thanks
Sierra
Re: Command to stop iteration
What language you using? C#? VB?Pixi6s wrote:I have my test cases set to "continue with iteration" because generally the show must go on. I do have one case within the first code module where if it does not find the correct page, than I want the current iteration to end and the next iteration to start.
Is there a programmatic way to ask the iteration to stop in one particular instance?
What operator are you using for iteration?
Report is saved as temp file in project folder. You can open it manuallyWhen I manually stop a run it doesn't bring up the report "so far" I find this annoying. I am in debug mode so I often don't need the entire test case to complete but I'd often like to view the log. Is this possible?
Re: Command to stop iteration
My bad, I am in Ranorex 3.0.4 and my user code is in C#.
I'm not sure what you mean by operator. I have a SQL data source that it is iterating around...
Thanks
I'm not sure what you mean by operator. I have a SQL data source that it is iterating around...
Thanks
Re: Command to stop iteration
Generally, you should use "break" statement.
See details at MSDN
See details at MSDN
Re: Command to stop iteration
I did try it but it didn't work because I am not actively using a loop. My testcase has a SQL data source that it is iterating around. Under that testcase I have user code modules and recording modules that it iterates through. I'd like it to continue when a validation fails, but I need it to stop when it can't find the correct product page, or all the validations fail because it's testing the wrong product.
Thanks
Thanks
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Command to stop iteration
Hi,
Regards,
Tobias
Support Team
you can do this by calling Report.Failure(String) within you user code if you know, you are not in the correct product page. Report.Failure will make your iteration stop and by selecting "Continue with iteration" for Error behavior in your Test Case settings the next iteration will be executed.Pixi6s wrote:Is there a programmatic way to ask the iteration to stop in one particular instance?
Regards,
Tobias
Support Team
Re: Command to stop iteration
I updated my report call from report.log(reportlevel.failure, str, str) to report.failure(str, str) and it did not change the behavior. The test and current iteration still continues. Am I using it wrong?
Code: Select all
//Determine if correct deal is being tested
bool bCheckID = CheckDealID(DealID);
if (bCheckID == false)
{
bool bExist = repo.WebDocument.CorpSideBar.RelatedDeal1BuyInfo.Exists();
if (bExist)
{
repo.WebDocument.CorpSideBar.RelatedDeal1Buy.Click();
bCheckID = CheckDealID(DealID);
if (bCheckID == false)
{
bExist = repo.WebDocument.CorpSideBar.RelatedDeal2BuyInfo.Exists();
if (bExist)
{
repo.WebDocument.CorpSideBar.RelatedDeal2Buy.Click();
bCheckID = CheckDealID(DealID);
if (bCheckID == false)
{
Report.Failure("Correct Deal Cannot be found");
}
}else{
Report.Failure("Auto", "Correct Deal Cannot be found");
}
}
}else{
Report.Failure("Auto", "Correct Deal Cannot be found");
}
}
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Command to stop iteration
Hi,
does your method CheckDealID work correctly?
Do you get the failure message logged within your report?
Basically a failure message makes the test case fail.
Regards,
Tobias
Support Team
does your method CheckDealID work correctly?
Do you get the failure message logged within your report?
Basically a failure message makes the test case fail.
Regards,
Tobias
Support Team
Re: Command to stop iteration
Yes CheckDealID works correctly, it is very simple
Yes I do get the failure message logged into my report. (see attachment)
It doesn't seem to be working in my case. the rest of the code in that usercode executes as well as the next record module starting up.
Code: Select all
public static bool CheckDealID(string sExpectedID)
{
//Check ID
string sHref = repo.WebDocument.Corp.BuyButton.Href.ToString();
string sDealID = Util.Util.ReturnDealIDFromURL(sHref);
if (sDealID == sExpectedID)
{
return true;
}else{
return false;
}
}
public static string ReturnDealIDFromURL(string sUrl)
{
int x = sUrl.IndexOf("?id=") + 4;
return sUrl.Substring(x, sUrl.Length-x);
}
It doesn't seem to be working in my case. the rest of the code in that usercode executes as well as the next record module starting up.
You do not have the required permissions to view the files attached to this post.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Command to stop iteration
Hi,
Regards,
Peter
Ranorex Team
Sorry my colleague mixed something up. Report.Failure() logs a logical failure (e.g. test step failure) message and it doesn't abort the whole iteration. If you want to abort the whole iteration you have to throw a new exception. For example:Pixi6s wrote:It doesn't seem to be working in my case. the rest of the code in that usercode executes as well as the next record module starting up.
throw new RanorexException("text");But please choose the exception to your abort criteria. If you validate something please use ValidationException() and so on.
Regards,
Peter
Ranorex Team
Re: Command to stop iteration
Thank you, this call does do what I need. But it doesn't seem to print out my string to the log. Do I need to report out a log string before making this call?
Code: Select all
throw new Ranorex.ValidationException("Correct Deal Cannot be found");
You do not have the required permissions to view the files attached to this post.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Command to stop iteration
Hi,
This is a bug in our Software and we will fix this with Ranorex 3.0.5.
Meanwhile please log a Report.Info() or Report.Failure() before you throw the exception.
Regards,
Peter
Ranorex Team
This is a bug in our Software and we will fix this with Ranorex 3.0.5.
Meanwhile please log a Report.Info() or Report.Failure() before you throw the exception.
Regards,
Peter
Ranorex Team
Re: Command to stop iteration
Thanks works well thanks
Re: Command to stop iteration
Is there a command to stop an iteration that is not a failure? I now have a case where if it's a certain type of product to skip the iteration.
Thanks
Thanks
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Command to stop iteration
Sorry but such a functionality is not available. Just delete the iteration from your data-source and ranorex won't executed it.Pixi6s wrote:Is there a command to stop an iteration that is not a failure?
Regards,
Peter
Ranorex Team