TestSuiteRunner.Run and return value

Class library usage, coding and language questions.
alinaKava
Posts: 4
Joined: Thu Nov 12, 2015 6:34 pm

TestSuiteRunner.Run and return value

Post by alinaKava » Mon Jan 25, 2016 4:14 pm

Hi.
One or more test cases failed and after that in Program.cs after all test cases-
error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
in debug mode Run returns 0 and that's why
error = 0
If I press "Pause break" - Run returns -1 and
error = -1

How should I do that TestSuiteRunner.Run() returns -1 if any test case failed?

Thank you.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TestSuiteRunner.Run and return value

Post by Support Team » Wed Jan 27, 2016 1:30 pm

Hi alinaKava,

Unfortunately, I'm not exactly sure what's the current issue.

Generally, The TestSuiteRunner returns the error code 0 in case of success or the error code -1 in case of failure. There shouldn't be any difference when running the program with or without the debugger.

It would be great if you could describe the use case in more detail.
Additionally, may I ask to upload the compressed Ranorex Solution and a Ranorex Report of the corresponding test execution?

Thank you in advance.

Johannes
.
Image

alinaKava
Posts: 4
Joined: Thu Nov 12, 2015 6:34 pm

Re: TestSuiteRunner.Run and return value

Post by alinaKava » Wed Jan 27, 2016 2:01 pm

Some misunderstanding.
For example, see first report - in this case TestSuiteRunner return 0, but first test case failed. In second report TestSuiteRunner return -1 - I pressed Pause Break. I need , TestSuiteRunner return -1 if any test case failed like in first report. Thank you.
Attachments
report1.PNG
report1.PNG (38.13 KiB) Viewed 1320 times
report2.PNG
report2.PNG (54.36 KiB) Viewed 1320 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TestSuiteRunner.Run and return value

Post by Support Team » Wed Jan 27, 2016 4:00 pm

Hello alinaKava,

May I ask if you use the latest version of Ranorex and the latest version of the ReportToPDF Tool?
Please try to disable the code module ReportToPDF and check if the same issue occurs.

It would be great if you could upload the solution in order we can analyze the issue in detail.
If you want, you could also send the solution to [email protected].

I look forward to hearing from you.

Sincerely,
Johannes
.
Image

alinaKava
Posts: 4
Joined: Thu Nov 12, 2015 6:34 pm

Re: TestSuiteRunner.Run and return value

Post by alinaKava » Thu Jan 28, 2016 10:20 am

My solution is to add code module to test suite teardown

Code: Select all

 void ITestModule.Run()
        {
            TestSuite.TestSuiteCompleted += delegate {
        		IReportItem Failed = null; 
				if (TestReport.CurrentTestSuiteActivity != null)
				{
					foreach (IReportItem rep in TestReport.CurrentTestSuiteActivity.Children)  
					    if ((rep as Activity).Status == Ranorex.Core.Reporting.ActivityStatus.Failed)  
					        Failed = rep;  
					  
					if (Failed != null)  
					{  
						IsFailed = true;                                    
					}  
				}  
        	};
        }
And in Program.cs I added

Code: Select all

if (TestSuiteStatus.IsFailed) error = -1;
Thanks.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TestSuiteRunner.Run and return value

Post by Support Team » Tue Feb 02, 2016 4:16 pm

Hello alinaKava,

There was a bug in the ReportToPDF tool, which caused the incorrect return value.

The bug was fixed in the latest version of the ReportToPDF tool, which can be downloaded from the following web page: Download ReportToPDF

Sincerely,
Johannes
.
Image

alinaKava
Posts: 4
Joined: Thu Nov 12, 2015 6:34 pm

Re: TestSuiteRunner.Run and return value

Post by alinaKava » Wed Feb 03, 2016 1:58 pm

Thanks! It works.