Page 1 of 2

print test case status and failure message in teardown

Posted: Tue Dec 06, 2011 12:24 pm
by agiletestware
Hello,
How can I print the test case status and failure message/exception (if test failed) in the teardown script ?
Looking to just do something like

console.writeline("status:" + test.status)
if(test.status.failed)
console.write ("message: " + test.failuremessage)

Thanks

Re: print test case status and failure message in teardown

Posted: Tue Dec 06, 2011 4:24 pm
by Support Team
Hi,

At the moment there is no way how you can get the status in the teardown of the test case, but this is a known issue and we will add this functionality in one of our future releases.

Regards,
Markus
Ranorex Support Team

Re: print test case status and failure message in teardown

Posted: Wed Dec 07, 2011 7:46 am
by swmatisa
Hello,

Warkaround: I think you can do this with the IReportBuilder Interface and another application that display the messages.

I do something like this to know the number of testcases passes, failed or blocked on my VMs (with a simple UPD connection to tranfer data). see http://www.ranorex.com/forum/ranorex-re ... tml#p11489

I hope this help

Re: print test case status and failure message in teardown

Posted: Fri Jan 06, 2012 4:34 pm
by agiletestware
Hello Markus,
Do you have a date when this will be available. The last two releases do not have this feature (per the release notes)
http://www.ranorex.com/download/release ... html#c3788

Thanks

Re: print test case status and failure message in teardown

Posted: Mon Jan 09, 2012 4:52 pm
by Support Team
Hi,
agiletestware wrote:Do you have a date when this will be available. The last two releases do not have this feature (per the release notes)
This feature will be available with Ranorex 3.3.

Regards,
Peter
Ranorex Team

Re: print test case status and failure message in teardown

Posted: Mon Jan 09, 2012 5:25 pm
by agiletestware
What is the tentative release date for 3.3 ?

Re: print test case status and failure message in teardown

Posted: Mon Jan 09, 2012 5:31 pm
by Support Team
Hi,

I cannot tell you an exact date now, but it should be available end of Q1 or at the beginning of Q2.

Regards,
Peter
Ranorex Team

Re: print test case status and failure message in teardown

Posted: Mon Apr 09, 2012 10:55 pm
by agiletestware
Hello Peter,
Any update on when this will be available ?

Thanks

Ali

Re: print test case status and failure message in teardown

Posted: Tue Apr 10, 2012 10:37 am
by Support Team
Hi,

please be patient, it will be available soon...


Regards,
Tobias
Ranorex Team

Re: print test case status and failure message in teardown

Posted: Thu Apr 19, 2012 8:50 am
by Pavlo
Hi

I'm also interested in Ranorex v3.3 :wink:

I'm getting more and more tests with status "to be continued when Ranorex 3.3 released because can't verify cell color" (I've already posted my question and got answer here: http://www.ranorex.com/forum/how-to-get ... t3084.html)

Take your time - don't hurry with release - we need good and bug-less tool for automation :) - but let us know when Ranorex 3.3 is ready and please provide couple of examples how to use new features from it.

-re
Pavlo

Re: print test case status and failure message in teardown

Posted: Fri Apr 20, 2012 11:34 am
by Support Team
Hi Pavlo,
Pavlo wrote:on't hurry with release - we need good and bug-less tool for automation
As you said we don't want to hurry, because we want to deliver a stable product for our customers. We also have a complete new Plug-In "Android Plug-In" in this version and a lot of other nice features.

To be honest, I think the version will be available at end of May.

Regards,
Peter
Ranorex Team

Re: print test case status and failure message in teardown

Posted: Wed Jun 06, 2012 11:13 pm
by agiletestware
Hi Peter,
Do you know if this is now possible in the 3.3 release?
I did not see anything in the 3.3 release notes

Thanks

Re: print test case status and failure message in teardown

Posted: Mon Jun 11, 2012 11:22 am
by Support Team
Hi Pavlo,

I am afraid that this feature is not part of Ranorex 3.3. I have already added a feature request to our internal bug tracking system.

You can try the following code as workaround.
Please create a new UserCode Module at the beginning of the tear down area and insert this code. It will read all messages out of the activity stack and writes it into the console output.

Code: Select all

 [TestModule("F6E3A1C6-ABBB-46E2-B342-27AA82B323AF", ModuleType.UserCode, 1)]
    public class WriteErrorMessage : ITestModule
    {
        /// <summary>
        /// Constructs a new instance.
        /// </summary>
        public WriteErrorMessage()
        {
            // Do not delete - a parameterless constructor is required!
        }

        /// <summary>
        /// Performs the playback of actions in this module.
        /// </summary>
        /// <remarks>You should not call this method directly, instead pass the module
        /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
        /// that will in turn invoke this method.</remarks>
        void ITestModule.Run()
        {
            Mouse.DefaultMoveTime = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor = 1.0;
           
            var rootActivity = Ranorex.Core.Reporting.ActivityStack.Instance.RootActivity;
            	
            foreach (var activity in GetAllActivities(rootActivity))
            {
            	var errorMessage = activity.ErrorMessage;
            	if (!string.IsNullOrEmpty(errorMessage))
            		Console.WriteLine("Error message: " + errorMessage);
            }
        }
        
        IList<Activity> GetAllActivities(Activity rootActivity)
        {
        	var activities = new List<Activity>();
        	
        	foreach (var child in rootActivity.Children)
        	{
        		var activity = child as Activity;
        		if (activity != null)
        			AddActivitiesRecursive(activities, activity);	
        	}
        	return activities;
        }
        
        void AddActivitiesRecursive(IList<Activity> activities, Activity parent)
        {
        	foreach (var child in parent.Children)
        	{
        		var activity = child as Activity;
        		if (activity != null)
        		{
        			activities.Add(activity);
        			AddActivitiesRecursive(activities, activity);
        		}
        	}
        }
    }
I hope that I could help you with this workaround.

Kind regards,
Bernhard
Ranorex Support Team

Re: print test case status and failure message in teardown

Posted: Fri Sep 14, 2012 5:22 am
by agiletestware
hello,
Since this feature was not delivered in 3.3, do you know if it is being done in the next release?
Just need to be able to see how to print testcase name, status, assert messages (for failing tests)

I am not really sure the example below with the testmodule prints out testcase status, failure message etc

Thanks

Re: print test case status and failure message in teardown

Posted: Fri Sep 14, 2012 3:30 pm
by Support Team
Hi,

This feature was added in Ranorex 3.3.2 "The result of a test case iteration can now be evaluated within teardown modules".
The follwing forum post could also be of interest: Testcase iteration status in teardown.
You can get the status of the current test case with the following code:
Ranorex.Core.Testing.TestCase.Current.Status
, there are also other properties of the current test case instance which can be accessed, like the name.

Regards,
Markus
Ranorex Support Team