title: VS Team Test: .Net Unit Testing with Excel as Data Source: Adapter Failed
body: <p>I am trying to do Unit Testing with Excel as data source. I am getting the following exception. How do we correct it?</p>
  
  <blockquote>
    <p>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"</p>
  </blockquote>
  
  <hr>
  
  <pre><code>  [TestMethod]
    [Owner("Lijo ")]
    [TestProperty("TestCategory", "Developer"), 
        DataSource("Microsoft.ACE.OLEDB.12.0", 
       "Data Source=C:/Sheets/DataSheet.xlsx;Extended Properties=Excel 12.0;",
       "[Sheet1$]", 
       DataAccessMethod.Sequential)]
    public void ChangePasswordTest()
    {
  
       int a = Convert.ToInt32(TestContext.DataRow[0]); //(int)Column.UserId
       int b = Convert.ToInt32(TestContext.DataRow[1]);
       int expectedResult = Convert.ToInt32(TestContext.DataRow[2]);
  
       MyClass myObj = new MyClass(1, "P@ssw0rd");
       int actualResult = myObj.GetAdditionResult(a, b);
       Assert.AreEqual&lt;int&gt;(expectedResult, actualResult, "The addition result is incorrect.");
  
    }
  </code></pre>
  
  <hr>
  
  <p>Readings:</p>
  
  <ol>
  <li><p><a href="https://stackoverflow.com/questions/2783045/unit-testing-error-the-unit-test-adapter-failed-to-connect-to-the-data-source">Unit Testing Error - The unit test adapter failed to connect to the data source or to read the data</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/7548761/data-driven-unit-tests-problem">Data driven unit tests problem</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/2304549/how-to-create-startup-and-cleanup-script-for-visual-studio-test-project">How to create Startup and Cleanup script for Visual Studio Test Project?</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/288805/how-does-mstest-visual-studio-2008-team-test-decide-test-method-execution-order">How Does MSTEST/Visual Studio 2008 Team Test Decide Test Method Execution Order?</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/10218072/visual-studio-2010-ultimate-data-generation-plan-setting-incorrect-data-type-f">Visual Studio 2010 Ultimate - Data Generation Plan Setting Incorrect Data Type for Column</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/761462/how-should-i-unit-test-a-simple-crud-class">How should I unit-test a simple CRUD-class?</a></p></li>
  </ol>