Usage of EmailModule.cs and issues with variables

Ask general questions here.
Posts: 13
Joined: Thu May 09, 2019 10:03 am

Usage of EmailModule.cs and issues with variables

Post by dominik_F » Thu Jun 06, 2019 2:43 pm

Hi all,

i'm quite new to ranorex, so sorry if that question is too trivial.
I'm trying to use the EmailModule from the RanorexAutomationHelpers. Basically it works fine, as long as I only run a single TestSuite but not the whole solution. If a run the whole solution (currently 3 Testsuites each containing 1-3 Tests and a call to the mail module in the teardown), the variables seem to get mixed up (number of successful testcases, number of failed testcases, error count and and filename are wrong in the mail.

Or is the mail module intended to be used with a single testsuite only?
Do i need to wait some time to let ranorex finish everything before calling the mailmodule? (currently it's the only action taken in teardown beside closing the AUT)

EDIT: i have no data-binding so far, so all the variables are unbound. Though, the variables not working, are those defined at the beginning of the code from the "TestReport.CurrentTestSuiteActivity". Or do I need to use another one for this?

The Constructor looks like this:

Code: Select all

 public EmailModule()
        string result = TestReport.CurrentTestSuiteActivity.Status.ToString().ToUpper();
         string reportName = TestReport.ReportEnvironment.ReportName.ToString();
         int failedCount = TestReport.CurrentTestSuiteActivity.TotalFailedTestCaseCount;
         int successCount = TestReport.CurrentTestSuiteActivity.TotalSuccessTestCaseCount;
	 string path = "<path_to_solution>\\bin\\Debug\\Reports";				
        this.From = "------- from ----";
       	this.To = "----- to -----";
      	this.Subject = String.Format("{0} <{1}>", result, reportName);
      	this.Body = String.Format("The test run finished with return <{0}>.{1}Failed test cases: {2}{1}Successful test cases: {3}{1}{1} Detailed reports can be found on vietest01.uc.local at \"{4}\" ", result, Environment.NewLine, failedCount, successCount, path);
      	this.Username = "";
      	this.Password = "";
        this.ServerHostname = "----IP of exchange -----";
        this.ServerPort = "25";

       	this.SendEmailOnFailure = true;
    	this.SendEmailOnSuccess = true;
     	this.SendPdfReportOnComplete = true;

best regards,

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

Re: Usage of EmailModule.cs and issues with variables

Post by Support Team » Mon Jun 10, 2019 9:00 pm

Hello Dominik,

Based on the description of your current setup you have a teardown region with the EmailModule on each of your test suites (three total). If this is the case you should be receiving three individual emails, one for each test suite. If this is not the case, I recommend verifying the teardown is under the Test suite level and not the Test case. If possible please provide a copy of your solution compressed for review.

Create a Compressed Solution > ... -solution/

If you would like to discuss this issue in a more private manner you can create a support query referencing this thread with any relevant information here - and someone will be more than happy to assist!