Update XML for CI testing

Best practices, code snippets for common functionality, examples, and guidelines.
Tzahi
Posts: 16
Joined: Sun May 17, 2015 2:24 pm

Update XML for CI testing

Post by Tzahi » Mon Aug 03, 2015 8:09 am

Hi guys,

We want to enter my tests to our CI flow, but the person who responsible for it doesn't want to wait for .exe feedback (0 - success, 1 - fail), and prefer I will update the flow xml e.g for XML:

Code: Select all

<TestResult>
  <IsPass>false</IsPass>
</TestResult>
The only way I found to implement it was by "Convert To User Code" for each step,
adding try/catch block and calling "UpdateXML" function.
Is there a simple why to do it?

Ranorex (studio) Version: 5.3.2
Thanks
Tzahi
Best Regards
Tzahi Caspi

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

Re: Update XML for CI testing

Post by Support Team » Tue Aug 04, 2015 2:55 pm

Hi Tzahi,

I am afraid I don't understand what you are trying to do.
Do you want to update the CI system after each single action which was executed by Ranorex?

Do you already know our blogs about Integration? If not, please take a look at them, since they give a good insight how you could organize it with Ranorex.
Here is the link: Integration.

Regards,
Markus
.
Image

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Update XML for CI testing

Post by krstcs » Tue Aug 04, 2015 3:56 pm

I would suggest that you not try to do updates after each action. You should wait till the test is done and read the 0 or 1 returned by the exe. Both the initial work and the maintenance would be outrageous wastes of time given the limited value of the end result of semi-real-time updates.

If MY CI engineer had a problem with that (I AM my CI engineer, btw, as well as my own DBA, developer, integrator, etc.), I would tell them that that is just how Ranorex works. It will return the results at the end. But, if THEY want to do the work to make it work the way they want, they are more than welcome to write all the code.

But that's just me... :D
Shortcuts usually aren't...

Tzahi
Posts: 16
Joined: Sun May 17, 2015 2:24 pm

Re: Update XML for CI testing

Post by Tzahi » Thu Aug 06, 2015 7:58 am

Hi Markus,

Thanks for the link, my homework regarding CI came from Ranorex forums, and I think it's the correct way.
We actually use Nolio (no example for it but I got the idea).

Krstcs - I am sure that the correct why is to read 0 or 1 from each T.C. but the first team that start to work on it dictate the way, their way strange & complex, I simplified it by one XML and 3 status (run,fail,success).
BTW - try not to do cheers with all R&D team :wink:

Thanks guys for the info.
Best Regards
Tzahi Caspi

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

Re: Update XML for CI testing

Post by swmatisa » Thu Aug 06, 2015 9:26 am

Hello,

You can implment an IReportBuilder and generate this file easily: http://www.ranorex.com/forum/ranorex-re ... tml#p11489

Hope this helps
SW

Tzahi
Posts: 16
Joined: Sun May 17, 2015 2:24 pm

Re: Update XML for CI testing

Post by Tzahi » Sun Aug 09, 2015 3:01 pm

Hi Swmatisa,

Thanks a lot, but I stayed with XML solution (it works perfectly, I can elaborate if someone wants).
I didn't understand your solution, it looks great but I am not sure I can implement it.
It looks like a state machine (remind me Verilog :D ), that sampling the T.S.
Is it running as a different thread? different app (wpf you wrote)? which file its checks?

Anyway you gave me another idea, sampling the report data file for some data.
this file has the following values (plus many more):

Code: Select all

totalerrorcount="0"
totalwarningcount="0"
totalsuccesscount="2"
totalfailedcount="1"
totalblockedcount="0"
Best Regards
Tzahi Caspi

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

Re: Update XML for CI testing

Post by swmatisa » Tue Aug 11, 2015 12:39 pm

Hello,

In my previous sample, I have a class that send data to a wpf application.mIn your case, you can do all in Ranorex:

You must implement a little class like this (I didn't check with a compiler):

Code: Select all

using Ranorex.Core;

public class ProgressLogger : IReportLogger
{
	bool IReportLogger.PreFilterMessages {
	...
	// return always false
	}

	void IReportLogger.End()
	{
		// Write "success" of "fail" in your xml
	}
	
	
	// Treat Msg (error, warning...)
	void IReportLogger.LogData(ReportLevel level, string category, string message, object data, IDictionary<string, string> metaInfos){...}
	void IReportLogger.LogText(ReportLevel level, string category, string message, bool escape, IDictionary<string, string> metaInfos){...}

	void IReportLogger.Start()
	{
		// Write "run" in your xml
	}
}	
and call it from Main:

Code: Select all

public static int Main(string[] args)
{
	Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
	int error = 0;
	ProgressLogger l_Logger = new ProgressLogger();
	Report.AttachLogger(l_Logger);

	error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
...
Hope this helps
SW

Tzahi
Posts: 16
Joined: Sun May 17, 2015 2:24 pm

Re: Update XML for CI testing

Post by Tzahi » Sun Sep 20, 2015 2:32 pm

Hi Swmatisa,

Sorry for late response (summer time :D ).
I got your idea and love it (genius 8) ).
I didn't succeed to implement it since I got an error while try to inherit classes in Ranorex (ProgressLogger : IReportLogger).
I Even try to add Interface (the error wrote to add it), and it didn't help (somehow when I wrote it at MS-VS it worked).

Thanks a lot 8)
Best Regards
Tzahi Caspi