locked
config files while testing RRS feed

  • Question

  • I have certain config files in my application. When i run my unit tests, they fail saying that the config files cannot be found. Please suggest.
    Wednesday, March 29, 2006 6:49 AM

Answers

  • Hi Payal,

    Yes, that was a bug in beta version of VSTS. The actual bug was that if you added a config file to your project, VSTS would not automatically copy it to the output directory. So I have two suggestions for you

    1. Upgrade to RTM version !!! :) Many bugs were fixed
    2. To solve your actual problem
         a) Make sure your app config file has the name <your test project dll name>.dll.config
         b) In Solution Explorer, right click your app config file, choose properties
         c) In Properties window, change "Copy to Output Directory" from "Do not copy" to "Copy always"

    That should make it

    Thanks,
    David Gorena Elizondo
    [MSFT] VSTS


     

    Saturday, April 1, 2006 1:00 AM

All replies

  • Hi Payal,

    Can you provide more information on this,

    a) Are you using Visual Studio 2005?
    b) What language are you using? (C#, C++ ?)
    c) What kind of config files are you using, and how did you add them to your project?
    d) Can you provide the exact error message?

    Thanks,
    David Gorena Elizondo
    [MSFT] VSTS

    Wednesday, March 29, 2006 11:01 PM
  • hey david,

     - I am using Visual Studio 2005 (Beta version) with VB

     - The config file that i am using is there in the bin folder of my presentation layer. I have put it in the bin folder of my test project also.

     - The error message that is displayed is  - Could not find the config file

     

    Thanks

    Payal

    Friday, March 31, 2006 5:05 AM
  • Hi Payal,

    Yes, that was a bug in beta version of VSTS. The actual bug was that if you added a config file to your project, VSTS would not automatically copy it to the output directory. So I have two suggestions for you

    1. Upgrade to RTM version !!! :) Many bugs were fixed
    2. To solve your actual problem
         a) Make sure your app config file has the name <your test project dll name>.dll.config
         b) In Solution Explorer, right click your app config file, choose properties
         c) In Properties window, change "Copy to Output Directory" from "Do not copy" to "Copy always"

    That should make it

    Thanks,
    David Gorena Elizondo
    [MSFT] VSTS


     

    Saturday, April 1, 2006 1:00 AM
  • That works for the config file for the test project. However, if your application being tested has a config file, you still need to explicitly add it as a deployment item. This is because tests are always deployed when run, and config files for the code under test are not automatically deployed along with them. To do this:

    1. Open the test run config file for the test project.
    2. Go to the Deployment tab.
    3. Click Add File... and add the config file you need to be deployed.

    Then when you run tests using that run config file, the app's config file will be deployed. Alternately, you can add the DeploymentItem attribute to a test, e.g. [DeploymentItem(<path to config file>)]. But this only applies to one particular test, while the run config applies to all tests in the run.

    Saturday, April 1, 2006 1:08 AM
  • Kevin,

    You bring up an interesting point about the App Under Test (AUT) config file.   I noticed that when I run a test inside the Visual Studio IDE from the Test View, the AUT config file is not being used, even after I made sure was being correctly being deployed (via localtestrun.testrunconfig)

    What I've noticed is that the config file maintained by the the current settings.settings file in the VS solution is what is being used.  For example:

    App under test (Project1) has a settings.settings file which has a string value Test_String = "Hi there".  In method DoThis() there is the following call:  

    MessageBox.Show(Project1.Properties.Settings.Default.TEST_STRING);

    The associated test project (Project1.Test) has one test method, DoThisTest() which simply calls target.DoThis().    When I build Project1, the assemblies and project1.config file get correctly placed in the project1\bin\release directory.    The localtestrun.testconfig file has a deployment item for: project1\bin\release\project1.config

    Now I open project1\bin\release\project1.config and set Test_String = "release version"

    If I then run DoThisTest() from the IDE test view, I will unexpectedly see a message box with "Hi there"  because if I go to the test deployment directory from that test and open the project1.config file, I see Test_String = "release version".  If I run the Project1.exe file from within that deployment directory, only then do I see a message box with "release version" 

    According to this example, I cannot expect the deployed AUT.config file to be used when I run a test from within the Test View.  This does not seem like correct behavior.  

    thoughts?

     

    Tuesday, April 4, 2006 12:46 PM