Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7967137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:37:03+00:00 2026-06-04T06:37:03+00:00

I am trying to do Unit Testing with Excel as data source. I am

  • 0

I am trying to do Unit Testing with Excel as data source. I am getting the following exception. How do we correct it?

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”


  [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<int>(expectedResult, actualResult, "The addition result is incorrect.");

  }

Readings:

  1. Unit Testing Error – The unit test adapter failed to connect to the data source or to read the data

  2. Data driven unit tests problem

  3. How to create Startup and Cleanup script for Visual Studio Test Project?

  4. How Does MSTEST/Visual Studio 2008 Team Test Decide Test Method Execution Order?

  5. Visual Studio 2010 Ultimate – Data Generation Plan Setting Incorrect Data Type for Column

  6. How should I unit-test a simple CRUD-class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:37:04+00:00Added an answer on June 4, 2026 at 6:37 am

    Solved it myself in a different way. Other answers are welcome.

    Refer: Walkthrough: Using a Configuration File to Define a Data Source http://msdn.microsoft.com/en-us/library/ms243192.aspx

      [TestMethod]
      [DeploymentItem("C:/Sheets/DataSheet.xlsx")]
      [DataSource("MyExcelDataSource")]
      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<int>(expectedResult, actualResult, "The addition result is incorrect.");
    
      }
    

    App.Config

    <configuration>
    
    
    <configSections>
    
    <section name="microsoft.visualstudio.testtools" 
     type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    
     </configSections>
    
    
    
     <connectionStrings>
    
    <add name="MyExcelConn" 
         connectionString="Dsn=Excel Files;dbq=C:/Sheets/DataSheet.xlsx;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5" providerName="System.Data.Odbc" />
    
     </connectionStrings>
    
    
     <microsoft.visualstudio.testtools>
    
    
      <dataSources>
    
          <add name="MyExcelDataSource" 
          connectionString="MyExcelConn" 
          dataTableName="Sheet1$" 
          dataAccessMethod="Sequential"/>
    
      </dataSources>
    
    
    </microsoft.visualstudio.testtools>
    
    </configuration>
    

    For VS 2010, TestTools version used is Version=10.0.0.0

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting started with unit testing and trying to do some TDD. I've read
I'm trying to unit test, using VS unit testing facility following method. void Get(string
I am trying to learn unit testing. I am trying to unit test some
I am just getting started with JS Unit Testing and am trying out qUnit.
I'm trying to write a C# unit test with VS 2008's built-in unit testing
I am trying to unit test for data being input into a textbox (txtPrice).
I am new to unit testing and I am trying to test some of
I am trying to use boost-test, and in particular boost unit testing. I clearly
I'm trying to get better at unit testing my JavaScript. I have the following
I'm trying to start unit testing on my application (should have done so from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.