title: Data driven unit tests problem
body: <p>I'm having some troubles getting my unit tests to be setup to use an Excel .xlsx data source.</p>
  
  <p>My App.config file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/&gt;
    &lt;/configSections&gt;
    &lt;connectionStrings&gt;
      &lt;add name="TestData" connectionString="Dsn=Excel Files;dbq=TestData.xlsx;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5" providerName="System.Data.Odbc" /&gt;
    &lt;/connectionStrings&gt;
    &lt;microsoft.visualstudio.testtools&gt;
      &lt;dataSources&gt;
        &lt;add name="GetAllCellNamesTest" connectionString="TestData" dataTableName="GetAllCellNamesTest$" dataAccessMethod="Sequential"/&gt;
  &lt;/dataSources&gt;
  </code></pre>
  
  <p>
      </p>
  
  <p>I have verified that it is finding <code>TestData.xlsx</code>, and there is a sheet named <code>GetAllCellNamesTest</code>.</p>
  
  <p>In my unit test class, I have the following setup:</p>
  
  <pre><code>        [TestMethod()]
          [DeploymentItem("TestProject\\TestData.xlsx")]
          [DataSource("GetAllCellNamesTest")]
          public void GetAllCellNamesTest()
          {
              // ... test code
  </code></pre>
  
  <p><code>TestData.xlsx</code> is being copied to the test results directory and all the unit tests which don't try to reference the data source are passing.</p>
  
  <p>However, this one test is failing with the following message:</p>
  
  <pre><code>The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests" (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library.
  Error details: ERROR [42S02] [Microsoft][ODBC Excel Driver] The Microsoft Access database engine could not find the object 'GetAllCellNamesTest$'. Make sure the object exists and that you spell its name and the path name correctly. If 'GetAllCellNamesTest$' is not a local object, check your network connection or contact the server administrator.
  </code></pre>
  
  <p>I'm really not sure where in my setup is wrong, I followed this walkthrough on MSDN to get setup: <a href="http://msdn.microsoft.com/en-us/library/ms243192.aspx" rel="nofollow">Walkthrough: Using a Configuration File to Define a Data Source</a>. Note that I did change the <code>section</code> version to <code>10.0.0.0</code> because I am using .net 4.0 (per the note at the bottom of the page). </p>
  
  <p>edit: oh, and all files are located locally on my computer.</p>