none
Unit test out folder files are randomly deleted by VS RRS feed

  • Question

  • As part of my unit tests I'm writing to output folder (Out) various logs and files so I can examine after running my unit test.   For some reason the VS test runner is deleting these files (but not all of them). Is there some way to turn this behavior off?  I did not see any settings to configure this behavior.

    Matt

    Thursday, August 23, 2012 11:05 PM

Answers

  • The scenario is quite simple.  I am writing a unit test.  In my unit test I write files to the current directory.  I get the current directory by checking System.Directory.CurrentDirectory.   When the unit test runs, Visual Studio or the unit test runner sets the current directory to the Out folder.

    Some files I write to the Out folder remain after the test completes, some are deleted.  If I write a log file this remains for some reason.  If I write an XML file, this is deleted.  This apparently is the default behavior of Visual Studio test runner for VS.NET 2010.   It is easy enough to reproduce.

    In any case, I worked around the issue by creating my own test output folder and writing files to this folder, so I am no longer bothered by this behavior.


    Matt

    Tuesday, August 28, 2012 4:32 PM

All replies

  • Hi Matt,

    Thanks for posting your quesry on MSDN forum.

    Which VS version you are using?

    Assuming VS 2012, in case of successful test run, by default, out directory is deleted. You can override this behavior through runsettings in VS 2012. Create a <filename>.runsettings file with below contents and select in VS from menu TEST -> Test Settings -> Select Test Settings File

    <RunSettings>
      <MSTest>
        <DELETEDEPLOYMENTDIRECTORYAFTERTESTRUNISCOMPLETE>false</DELETEDEPLOYMENTDIRECTORYAFTERTESTRUNISCOMPLETE>
      </MSTest>
    </RunSettings>

    Note: For Out folder creation there should be DeploymentItem on atleast one of the testmethod/testclass in test assembly.


    Regards,
    Vikram Agrawal,
    Developer, VSTLM, Microsoft Corporation


    Friday, August 24, 2012 7:24 AM
  • Does this work with VS.NET 2010?  I'm not yet using 2012.  I can create *.runsettings file but I cannot select it as the "Active Test Settings".  I can create *.testsettings file and select as "Active Test Settings".   Can I add this setting to the *.testsettings file in VS 2010?

    Also, where can I get XSD for http://microsoft.com/schemas/VisualStudio/TeamTest/2010 ?


    Matt

    Friday, August 24, 2012 4:46 PM
  • Hi Matt,

    Each test run folder contains a folder named Out. The Out folder is the actual deployment folder. Assemblies and other files or folders that are required for the test run are copied to the <solution>\TestResults\<test run>\Out folder every time that a test run is started.

    Here is a help link about how to configure test deployment:

    http://msdn.microsoft.com/en-us/library/ms182475.aspx

    You said that “For some reason the VS test runner is deleting these files (but not all of them)”.

    I would like to know which kind of files VS is deleting. Are files like assemblies that are required for test run deleted? Or are files that you wrote into this folder deleted?

    In addition, you said you want to turn this behavior off, I would like to know whether you want to stop deleting during test run or not.

    If possible, you could provide more detailed information.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, August 28, 2012 11:19 AM
    Moderator
  • The scenario is quite simple.  I am writing a unit test.  In my unit test I write files to the current directory.  I get the current directory by checking System.Directory.CurrentDirectory.   When the unit test runs, Visual Studio or the unit test runner sets the current directory to the Out folder.

    Some files I write to the Out folder remain after the test completes, some are deleted.  If I write a log file this remains for some reason.  If I write an XML file, this is deleted.  This apparently is the default behavior of Visual Studio test runner for VS.NET 2010.   It is easy enough to reproduce.

    In any case, I worked around the issue by creating my own test output folder and writing files to this folder, so I am no longer bothered by this behavior.


    Matt

    Tuesday, August 28, 2012 4:32 PM
  • Does this work with VS.NET 2010?  I'm not yet using 2012.  I can create *.runsettings file but I cannot select it as the "Active Test Settings".  I can create *.testsettings file and select as "Active Test Settings".   Can I add this setting to the *.testsettings file in VS 2010?

    Also, where can I get XSD for http://microsoft.com/schemas/VisualStudio/TeamTest/2010 ?


    Matt

    hi, I am looking for a similar solution to this problem where i can add the settings in just the testsettings file as i am also using that extensively for the tests without which my tests won't even execute. 

    It would be great if you could direct how you solved the problem.


    mohit narang

    Monday, August 5, 2013 9:30 AM