none
Unit Test Adapter threw exception: Data source 'MyDataSource' cannot be found in the test configuration settings

    Frage

  • a data driven unit test followed http://msdn.microsoft.com/en-us/library/ms243192%28v=VS.90%29.aspx throws following error message:

    Unit Test Adapter threw exception: Data source 'MyDataSource' cannot be found in the test configuration settings..

    only thing changed is I am using a SQL server connection instead of Excel file

    tried following but no luck:

    1. for App.config, Build Action=Content, Copy to Output Directory=Copy always

    2. add Web.config to test project and did same thing as App.config

     

    if I use [DataSource("providername","conn string","tablename",sequential_access)] then everything works

    Please help! Thx!

     

     

    Samstag, 9. Juli 2011 00:02

Alle Antworten

  • Hi,

    You need to add app.config to the test project and your any connection string even the project that will be tested  to it so it can be used during executing the test.

    Thansk

    M.Radwan


    We are volunteers, if the reply help you mark it as your answer. thanks!!
    My Blog
    Samstag, 9. Juli 2011 10:59
  • Thanks Radwan.

    However, this still does not work in my case. I found if the project to be tested is a console application then the data source defined in App.config works OK but if the project is Web application, it still throws same error.

    One possible reason I think is, if it is a console application, when I step into the test method I can fine System.IO.Directory.GetCurrentDirectory is MyProject\Test Result\Out\, and there is testproject.dll.config file there; but it becomes c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ when it is a Web application, and there is no config file, of course.

    Anyone has a working copy to show how data source is defined in a configuration file for ASP.net web application? Thanks!

    Montag, 11. Juli 2011 20:29
  • Hi

    I know its probably way too late to comment ...but I guess thats one of the beauties of forums ,

    Errm in regards to your problem .... I have the same issue, when I try to run the test but when I go to debug it then it seems to work 

    so if you are desperate for a test run a debug should do,

    But i am still trying to figure it out.... any solutions you got in the end ?? ?  

    Donnerstag, 1. März 2012 14:07