How to run multiple project

Ask general questions here.
syuhada
Posts: 28
Joined: Mon Sep 20, 2010 7:56 am

How to run multiple project

Post by syuhada » Mon Sep 20, 2010 8:47 am

hi;
i have solution file that contains a few of project. I want to run program.cs for all project in a new solution file.
how can i do to call the program.cs for all project.

thanks;

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

Re: How to run multiple project

Post by Support Team » Mon Sep 20, 2010 9:50 am

Hi,

you can manage this problem by creating a public class in one project and referencing this class in the other projects.
  • Create a new solution in the Ranorex Studio.
  • Add a second project to the solution.
  • Add a reference of the first project to the second via the context menu item 'Add Reference' (rightclick on second project). You can find your project under the tab projects.
  • Now you can use the code of the first project in the second project too.
Regards,
Tobias
Ranorex Team

syuhada
Posts: 28
Joined: Mon Sep 20, 2010 7:56 am

Re: How to run multiple project

Post by syuhada » Tue Sep 21, 2010 2:18 am

i already call the recording file in program.cs to run the test. Can i call program.cs only, because i have a lot of recording file.

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

Re: How to run multiple project

Post by Support Team » Tue Sep 21, 2010 8:46 am

Hi,

so you want to start all of your projects in just one project's program.cs.
  • Just add a reference of each of your projects to the first project (via the context menu item 'Add Reference') and make the 'Program' class of each of them public to allow access to their 'Main' methods.

    Code: Select all

    public class Program
    
  • now you can start each of your projects in first project's program.cs with following code:

    Code: Select all

    // Start playback of recording of first Project
    Recording1.Start();
    // Start Main methods of the other projects
    <name_of_project2>.Program.Main(null);
    <name_of_project3>.Program.Main(null);
    ...
    
  • To ensure to not override your log files you either have to choose a unique logfile name for each of your projects:

    Code: Select all

    string logFileName = "<logfilename>.rxlog";
    Report.Setup(ReportLevel.Info, logFileName, true);
    
    or - to store all logs to just one file - you have to enable the 'appendExisting' option when setting up your Report:

    Code: Select all

    Report.Setup(ReportLevel.Info, logFileName, true, true);
    
Regards,
Tobias
Ranorex Team
.
Image

syuhada
Posts: 28
Joined: Mon Sep 20, 2010 7:56 am

Re: How to run multiple project

Post by syuhada » Wed Sep 22, 2010 4:19 am

hi ;

thanks a lot for your code..It works as needed.. :D

But i have one more question to ask. If i run the test and an error occurs and Ranorex will stop the process. How can i do to ask Ranorex proceed to the next test although there has an error occurs.
thanks ;

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

Re: How to run multiple project

Post by Support Team » Wed Sep 22, 2010 7:49 am

Hi,

You have to set the exceptionOnFail parameter to false if you would like to continue your test script on failed validation.

Therefore you have to convert your validation into user code via the context menu.

Now set the exceptionOnFail parameter for the following overload method:

Code: Select all

    public static bool Attribute(
       Element element,
       string name,
       Regex regex,
       string message,
       bool exceptionOnFail
    )
Example:

Code: Select all

Validate.Attribute(repo.FormCalculator.OutputText, "text", "24", "Validate result", false);
Please also take a look to following post
http://www.ranorex.com/forum/executing- ... t1446.html

Regards,
Tobias
Ranorex Team
.
Image

syuhada
Posts: 28
Joined: Mon Sep 20, 2010 7:56 am

Re: How to run multiple project

Post by syuhada » Thu Sep 23, 2010 9:53 am

i will try on that solutions. one more ques to ask..why sometimes my Report log didnt displayed after run the test?
and this is my program.cs

Code: Select all

  public class Program
    {
        [STAThread]
        public static int Main(string[] args)
        {
            Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
            int error = 0;

            string logFileName = "Test.rxlog";

            Report.Setup(ReportLevel.Info, logFileName, true);
             
            try
            {
                //TODO: Code here - for example:
				
                  SCED2003.Start();
                 close.Start();
                SCED2004.Start();
                 close.Start();
                SCED2005.Start();
                 close.Start();
                SCED2006.Start();
                 close.Start();
                            
           
            }
            catch (ImageNotFoundException e)
            {
                Report.Error(e.ToString());
                Report.LogData(ReportLevel.Error, "Image not found", e.Feature);
                Report.LogData(ReportLevel.Error, "Searched image", e.Image);
                error = -1;
            }
            catch (RanorexException e)
            {
                Report.Error(e.ToString());
                Report.Screenshot();
                error = -1;
            }
            catch (ThreadAbortException)
            {
                Report.Warn("AbortKey has been pressed");
                Thread.ResetAbort();
                error = -1;
            }
            catch (Exception e)
            {
                Report.Error("Unexpected exception occured: " + e.ToString());
                error = -1;
            }
            
			//Report.Setup(ReportLevel.Info, logFileName, true,true);
            Report.End();
            return error;
        }
    }



thanks.
}


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

Re: How to run multiple project

Post by Support Team » Thu Sep 23, 2010 12:32 pm

Hi,
syuhada wrote:i will try on that solutions. one more ques to ask..why sometimes my Report log didnt displayed after run the test?
You really get no report or you get only few parts of your report? If you get only a few parts of the report, please set for all "Report.Setups" the appending flag to true. Please take a look to following API Documentation http://www.ranorex.com/Documentation/Ra ... etup_1.htm

Regards,
Peter
Ranorex Team
.
Image

syuhada
Posts: 28
Joined: Mon Sep 20, 2010 7:56 am

Re: How to run multiple project

Post by syuhada » Mon Sep 27, 2010 8:25 am

Hello;

sory for the late replay..
here is my problem,

i have one project name (runAll).This project is to call all project(program.cs) like your suggest earlier.After run the "runAll" project, i would like the report is send via email in one log only. i write the code in all project. but it send me the report for each single project.
This is my code for every program.cs(i refer to your code "customLogging").

Code: Select all

Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
            int error = 0;

            string logFileName = "Test.rxlog";

           
            // append to an existing file with the same name
            Report.Setup(ReportLevel.Info, logFileName, true);
            
            // set the host name of the SMTP server to use
            MailLogger.Host = "yourSmtpServer";
            // add a report logger that sends reports via email
            MailLogger mailLogger = new MailLogger("[email protected]", "[email protected]",
                                                   "Ranorex Report for CustomLogging");
            Report.AttachLogger(mailLogger);
            
            // add some custom HTML message to the XML report
            Report.LogHtml(ReportLevel.Info, "Link", "<a href='http://www.ranorex.com/'>Visit www.ranorex.com!</a>");

i also add class file (mailloging.cs for every project)..

thank you .. :wink: ..

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

Re: How to run multiple project

Post by Support Team » Mon Sep 27, 2010 2:45 pm

Hi,

You have to call the Report.Setup() method in each Project and the filename of the logfile should be always the same. Except in RunAll project use following overload for the Report.Setup() method
//The last true is for appending to the existing report
Report.Setup(ReportLevel.Info, logFileName, true, true);
and please use overall projects the same logfilname.
At your RunAll project please use following Report.Setup() method
//In this case we don't append to the report, because when you execute
//the RunAll project a new report will be generated.
Report.Setup(ReportLevel.Info, logFileName, true);
Now you should get only one Ranorex Report.

Regards,
Peter
Ranorex Team
.
Image

syuhada
Posts: 28
Joined: Mon Sep 20, 2010 7:56 am

Re: How to run multiple project

Post by syuhada » Tue Sep 28, 2010 2:28 am

hello Peter,

The way you suggest still cannot work. mayb got some mistake in my code..it displayed the report correctly in Ranorex. But not sending the whole report that was displayed in ranorex.

I received 3 single report for first project i had run( Infra.SCBR.). im not received any report for (Infra.TTL).

where i need to put the " Report.Setup(ReportLevel.Info, logFileName, true)"? Is my code below is correct or i need to put this setup before "Report.End" .

This is my program.cs in RunAll.

Code: Select all


 string LogFileName="Test.rxlog";
// append to an existing file with the same name
           
         Report.Setup(ReportLevel.Info, logFileName, true);
           
            // set the host name of the SMTP server to use
            MailLogger.Host = "yourSmtpServer";
            // add a report logger that sends reports via email
            MailLogger mailLogger = new MailLogger("[email protected]", "[email protected]",
                                                   "Ranorex Report for CustomLogging");
            Report.AttachLogger(mailLogger);
            

try
{
Infra.SCBR.Program.Main(null);
Infra.TTL.Program.Main(null);
}
Thanks for your helped.

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

Re: How to run multiple project

Post by Support Team » Tue Sep 28, 2010 10:17 am

Hi,

As I described in my last post, please check if at each project the appending parameter is set to true and if each project has the name log-filename.

Regards,
Peter
Ranorex Team
.
Image