Ask a Question

Log.SaveResultsAs() returns false when test fails

Occasional Contributor

Log.SaveResultsAs() returns false when test fails



I'm trying to export my test results to XML and I'm noticing that the Log.SaveResultsAs() method fails when my test fails. But succeeds when my test passes. I'm not sure why that would be the case. This is the line of code, I check the "success" variable:


var success = Log.SaveResultsAs("..\\XmlTestResults\\TestResults.xml", 0, true, 0);


Is there a way to get more information apart from a return value of just true or false?


My test is run in a VM via a Network Suite and this SaveResultAs is the last Test Item in the project to be run on the host. Attached are my Playback Project Settings.

Esteemed Contributor

When you say that your test fails, what do you mean?  The reason I ask is that a failure in the test MAY be an error in the TestLog that is actually logged... OR it could be a syntax error in your test that causes the project to fail before it even attempts to write a test log.

If we could have a bit more info on the "failure", that would help... in the meantime, your code looks fine.

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Occasional Contributor

Hi Robert,


The test failure is a file comparison fail (I expected it to fail because I added the difference myself). It is this bit of code:


if (Files.CrashReport_config.Check(systemDrive + "\\ProgramData\\Company\\CrashReport.config"))
    Log.Checkpoint("GID235250_InstallLogging: User Details are correctly written to C:\\ProgramData\\Company\\CrashReport.config");
    Log.Error("GID235250_InstallLogging: User Details are NOT correctly written to C:\\ProgramData\\Company\\CrashReport.config");


The Check returns false which produces the attached logs. Log1.jpg shows the Check method writing an Error to the log due to the file difference. Log2.jpg shows the file difference. Log3.jpg shows the test moving on to the next Test Item which is the SaveResultAs method.


From other tests which I have executed since my original post, I am able to get that SaveResultAs method to work in situations where I've encountered an error in a test and aborted that test due to my "Stop on error" setting. It appears it's this particular scenario with the file comparison that's not behaving properly.

Showing results for 
Search instead for 
Did you mean: