app.config配置
测试方法
excel 文件中第一行为列名 OrderHistorySearchCriteria
- <?xml version="1.0" encoding="utf-8" ?>
- <configuration>
- <configSections>
- <section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
- </configSections>
- <!--add below line(s) for datadriven test.-->
- <connectionStrings>
- <add name="MyExcelConn" connectionString="Dsn=Excel Files;dbq=Unit Test Data for FindOrders.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>
- [DeploymentItem("Unit Test Data for FindOrders.xlsx")]
- [DataSource("MyExcelDataSource"), TestMethod]
- public void TestMethodUsingExcel()
- {
- string xmlstring = TestContext.DataRow["OrderHistorySearchCriteria"].ToString();
- }
excel 文件中第一行为列名 OrderHistorySearchCriteria