Ask a Question

How can I export log files for project test items separately?

SOLVED
whuang
Regular Contributor

How can I export log files for project test items separately?

Hi everyone,

 

I was wondering if there is a way I can export log files for project test items separately?. I would like to keep a copy of the logs for the test that passed when doing regression, but it is not always so lucky that all tests can pass at once. The Log.SaveResultsAs methods exports the log files for the entire project, but I would like to export log files for project test items separately one by one, is there anyway to do that?

 

Thanks!

15 REPLIES 15
tristaanogre
Esteemed Contributor

You need to make sure that the file name you present in the method has the extension.  It won't automatically add the extension.  So "Call Log.SaveResultsAs("C:\Users\whuang\Downloads\try.mht", lsMHT)"

 

For detecting if there is an error, Log.ErrCount (https://support.smartbear.com/testcomplete/docs/reference/project-objects/test-log/log/errcount.html) gives you the count of error records written to the log.  So, just do a check if ErrCount > 0 for anything you want to do for errors.


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
whuang
Regular Contributor

Thanks @tristaanogre that's exactly what I wanted.

whuang
Regular Contributor

Hi @tristaanogre I just noticed Log.SaveResultsAs exports all the log files for entire project/test set. Is there any way I can export log files for each test item in a test set separately? Say I have a test project of 3 tests, after executing each test item, export the log file for that test item only, I don't need 3 copies of the first test item.

tristaanogre
Esteemed Contributor

Check out the "scope" parameter.

 

https://support.smartbear.com/testcomplete/docs/reference/project-objects/test-log/log/saveresultsas...


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
whuang
Regular Contributor

Yes, I did used "lesCurrentTestItem" for the scope in the method, but it still gave me the log files for the entire test set. Here is what I did, I called Log.SaveResultsAs(FileName, lsMHT, True, lesCurrentTestItem) method at the very last step of every single of my test, and I have a test set that has list of tests. So when I ran the test set, it exported me a log file for the first test item when the execution for the first one is done, this is what I want - a log file for the current running test item. but when it finished executing the second test item, it exported me a log file that had both the first and the second test item, this is not what I need, I only want the log file for the second test item, I already had the log file for the first test item, I don't want it again.

whuang
Regular Contributor

If there is no TC buildin funtion to export log files for project test items separately, is there anyway I can automate the manual export work? like writing a bat file? Any suggestion?

 

Thanks in advance!

cancel
Showing results for 
Search instead for 
Did you mean: