Logging using the API

Class library usage, coding and language questions.
tmcpherson
Posts: 14
Joined: Tue Nov 08, 2016 4:24 pm

Logging using the API

Post by tmcpherson » Fri Feb 03, 2017 10:39 pm

Hey everyone,

I've been experimenting with logging using just the Ranorex API. I am not using Ranorex Studio.

I've tried a few different things to make my code give me rxlogs that look nice. None of them have worked particularly well. They all look more or less like this:
[TestMethod]
public void Sample_Test_Should_Always_Pass()
{
    var count = 0;
    var testSuiteName = "totally a test suite " + count++;
    var testCaseName = "probably a test case " + count++;
    TestReport.Setup(ReportLevel.Debug, ".\\testingranorex.rxlog", true);

    TestReport.BeginTestSuite(testSuiteName);
    TestReport.BeginTestCase(testCaseName);

    Ranorex.Report.Info("this is an informative message");
    Ranorex.Report.Debug("bugz");
}
I'll attach the rxlog generated by this code too. (Except instead apparently I can only upload a screenshot of the rxlog, so that's attached.)

So. What am I missing here?
Attachments
rxlog.JPG
rxlog.JPG (43.95 KiB) Viewed 638 times

jma
Posts: 111
Joined: Fri Jul 03, 2015 9:18 am

Re: Logging using the API

Post by jma » Mon Feb 06, 2017 1:19 pm

Hey,

You will need to start a test module within the test case.

Code: Select all

TestReport.BeginTestCase("First Test Case");    
  TestReport.BeginTestModule("First module");
    Ranorex.Report.Info("this is an informative message");  
    Ranorex.Report.Debug("bugz");  
  TestReport.EndTestModule();
TestReport.EndTestCase();
I hope that helps!

tmcpherson
Posts: 14
Joined: Tue Nov 08, 2016 4:24 pm

Re: Logging using the API

Post by tmcpherson » Mon Feb 06, 2017 3:09 pm

That is exactly the information I needed. Thanks!