Aggregate High Level Text Report

Experiences, small talk, and other automation gossip.
msavoie
Posts: 1
Joined: Mon Apr 04, 2016 4:12 pm

Aggregate High Level Text Report

Post by msavoie » Mon Apr 04, 2016 4:34 pm

Hi,

I am currently working with C# in Ranorex 5.2.4. I have custom reporting enabled and am happy with the functionality. However, I additionally would like to store some very particular items in a text file every time a test is run, regardless of which test suite I run.

For example, I would have a text file called C:\aggregatelog.txt. Inside, each line would hold pass or fail data about recording modules. It would not hold the individual steps, just the start time, end time, module name, and path (e.g., project name > testsuite parent name > testsuite current name). The data would be continually appended on new lines, possibly broken up as the file gets large. Ideally, I would only need to add the code or change the functionality in one place per project instead of creating user code for each recording module or appending a code module at the end of each test suite, but I am open it if those are the best options.

My purpose in this is to have a single location to save and load data from for posting metrics to management. They would like to see how many times specific suites and modules run, how many times they pass/fail, and how long each module/testsuite/project take to run. I can gather all of this from individual custom report files if I can combine the data, but it would be easier going forward if I had a method of doing that while the tests are running.

If you can help I would appreciate it. Also, if you can think of a better way to approach this, that would also be helpful. I'm open to whatever suggestions you may have.



Thanks,
Matthew

asdf
Posts: 174
Joined: Mon Mar 21, 2016 3:16 pm

Re: Aggregate High Level Text Report

Post by asdf » Thu Apr 07, 2016 12:51 pm

Hi msavoie,

For example, you could write a code module with the following content.
public void textlog()
		{
			
			string[] status = {Ranorex.Core.Reporting.ActivityStatus.Success.ToString(),
				Ranorex.Core.Reporting.ActivityStatus.Failed.ToString(),
				Ranorex.Core.Reporting.ActivityStatus.Ignored.ToString()};
			string LogText = System.DateTime.Now.ToLongTimeString()+"\t"+TestSuite.Current.Name+"\t"+TestCase.Current.Name;
			string TCStatus = "";
			
			if (Ranorex.Core.Testing.TestCase.Current.Status.Equals(Ranorex.Core.Reporting.ActivityStatus.Success))
				TCStatus="\t"+status[0];
			
			else if(Ranorex.Core.Testing.TestCase.Current.Status.Equals(Ranorex.Core.Reporting.ActivityStatus.Failed))
				TCStatus="\t"+status[1];
			
			else if(Ranorex.Core.Testing.TestCase.Current.Status.Equals(Ranorex.Core.Reporting.ActivityStatus.Ignored))
				TCStatus="\t"+status[2];
			
			System.IO.File.AppendAllText(@"C:\\Log.txt",LogText+TCStatus+Environment.NewLine);
		}
After that, copy this code module in every Teardown-Section of your TestCases.

Hope that helps.

Kind Regards,

asdf