DataDriven Unit Test using Excel in VS2013

I am creating a Datadriven Unit (MS Unit Test) using an Excel file (*. Xlsx) as a data source. this is a mistake with the following error

Reverse message: the unit test adapter could not connect to the source data or to read data. For more information on troubleshooting this error, see the "Troubleshooting Data Management Issues" section. ( http://go.microsoft.com/fwlink/?LinkId=62412 ) in the MSDN library. Error Details: ERROR [IM014] [Microsoft] [ODBC Driver Manager] The specified DSN contains an architecture mismatch between the driver and the Application

I set the Copy to Output directory: always for DateRangeTest.xlsx I also tried defaultdir=.\;, defaultdir=.;anddefaultdir=c:\projectName\bin\debug\;

Here is the section from app.config

<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="DateRangeConstr" 
      connectionString="Dsn=Excel Files;dbq=DateRangeTest.xlsx;defaultdir=.\; driverid=790;maxbuffersize=2048;pagetimeout=5" 
      providerName="System.Data.Odbc" />
  </connectionStrings>
  <microsoft.visualstudio.testtools>
    <dataSources>
      <add name="DateRangeTestDataSource" 
        connectionString="DateRangeConstr" 
        dataTableName="Sheet1$" 
        dataAccessMethod="Sequential"/>
    </dataSources>
  </microsoft.visualstudio.testtools>
+4
source share
2 answers

Here are (2) options - you can either remove the DSN requirement , or set the opposite of the execution speed of the Excel / Access Office product that you installed.

Option 1 - remove the DSN from the connection string

Change this:

<add name="DateRangeConstr" 
    connectionString="Dsn=Excel Files;dbq=DateRangeTest.xlsx;defaultdir=.\; driverid=790;maxbuffersize=2048;pagetimeout=5" 
    providerName="System.Data.Odbc" />

For this:

<add name="DateRangeConstr" 
    connectionString="dbq=DateRangeTest.xlsx;defaultdir=.\; driverid=790;maxbuffersize=2048;pagetimeout=5" 
    providerName="System.Data.Odbc" />

Option 2 - Install ODBC Drivers for the Opposite Witness

, Office 2010 Office 2013.

, Excel Files DSN x86 x64 .

  • 32- ODBC: %WINDIR%\SysWOW64\odbcad32.exe
  • 64- ODBC: %WINDIR%\System32\odbcad32.exe

" Excel", "", . "" , , .

+3

- , Excel.

, Visual Studio Data Source Explorer.

. , Data Driven (Parameters) Visual Studio.

Writing a Data Driven Unit Test using MS Excel as a Data Source Using MS Visual Studio Unit Testing Tools 2013, 2015 or 2017

0

Source: https://habr.com/ru/post/1530537/


All Articles