print test case status and failure message in teardown

Class library usage, coding and language questions.
agiletestware
Posts: 10
Joined: Tue Dec 06, 2011 9:11 am

print test case status and failure message in teardown

Post by agiletestware » Tue Dec 06, 2011 12:24 pm

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

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

Re: print test case status and failure message in teardown

Post by Support Team » Tue Dec 06, 2011 4:24 pm

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
.
Image

swmatisa
Posts: 122
Joined: Fri Aug 05, 2011 7:52 am

Re: print test case status and failure message in teardown

Post by swmatisa » Wed Dec 07, 2011 7:46 am

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
SW

agiletestware
Posts: 10
Joined: Tue Dec 06, 2011 9:11 am

Re: print test case status and failure message in teardown

Post by agiletestware » Fri Jan 06, 2012 4:34 pm

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

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

Re: print test case status and failure message in teardown

Post by Support Team » Mon Jan 09, 2012 4:52 pm

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
.
Image

agiletestware
Posts: 10
Joined: Tue Dec 06, 2011 9:11 am

Re: print test case status and failure message in teardown

Post by agiletestware » Mon Jan 09, 2012 5:25 pm

What is the tentative release date for 3.3 ?

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

Re: print test case status and failure message in teardown

Post by Support Team » Mon Jan 09, 2012 5:31 pm

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
.
Image

agiletestware
Posts: 10
Joined: Tue Dec 06, 2011 9:11 am

Re: print test case status and failure message in teardown

Post by agiletestware » Mon Apr 09, 2012 10:55 pm

Hello Peter,
Any update on when this will be available ?

Thanks

Ali

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

Re: print test case status and failure message in teardown

Post by Support Team » Tue Apr 10, 2012 10:37 am

Hi,

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


Regards,
Tobias
Ranorex Team
.
Image

Pavlo
Posts: 43
Joined: Fri Dec 30, 2011 10:55 am

Re: print test case status and failure message in teardown

Post by Pavlo » Thu Apr 19, 2012 8:50 am

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

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

Re: print test case status and failure message in teardown

Post by Support Team » Fri Apr 20, 2012 11:34 am

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
.
Image

agiletestware
Posts: 10
Joined: Tue Dec 06, 2011 9:11 am

Re: print test case status and failure message in teardown

Post by agiletestware » Wed Jun 06, 2012 11:13 pm

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

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

Re: print test case status and failure message in teardown

Post by Support Team » Mon Jun 11, 2012 11:22 am

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
.
Image

agiletestware
Posts: 10
Joined: Tue Dec 06, 2011 9:11 am

Re: print test case status and failure message in teardown

Post by agiletestware » Fri Sep 14, 2012 5:22 am

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

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

Re: print test case status and failure message in teardown

Post by Support Team » Fri Sep 14, 2012 3:30 pm

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
.
Image