简体   繁体   中英

How to automatically delete Test Results in visual studio test controller

I am running coded UI test cases in agent machine through MTM. And for each run the test results gets generated in controller machine as you can see in the screenshot below. 在此处输入图片说明

As you can see that each run generates above two folders in controller AppData > local > VSTQT > QTController > run_number_folder folder

I need only Results folder and I want to delete the Deployment folder after each run in finished.

Is there a way to do it?

Note : I am using Test Agent and Test Controller 2013 Update 5

Within the code of the tests, the TestContext which is used by all Coded UI tests contains several directory fields. The DeploymentDirectory field appears to be the one you need.

I do not think you can delete this directory and all its contents in one go because, as you write in a comment, it will be open and in use by part of the test suite. You should be able to scan through its files and subdirectories and delete most of them one by one, skipping over any that are already in use.

Another possibility is to create a cleanup script that will be called from the "Setup and cleanup scripts" part of the .testsettings file in the solution. As above, some parts may not delete as they are already in use.

Since you are running a coded UI test you could have some piece of code at the end that would find your deployment directory and delete it. As it shows you know your user and until QTController your path will be always the same, so you just have to find the deployment directory under that and remove it.

If you are running your tests from a build/release, you could add a powershell script after the test to delete your deployment directory.

To find the directory:

string[] dirs = Directory.GetDirectories(@"c:\users\user_name\appdata\local\vseqt\qtcontroller\", "deployment", System.IO.SearchOption.AllDirectories);

foreach(string dir in dirs)
{
   Directory.Delete(dir);
}

You could define your retention policie for the results as well. Please see https://docs.microsoft.com/en-us/vsts/manual-test/getting-started/how-long-to-keep-test-results?view=vsts

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM