接着,上面的测试代码就得改成下面的样子:
[TestClass] public class UsersTest { // 测试数据文件的名称与测试用例所在的类型名相同 [DeploymentItem("UsersTest.xls")] // 每一个测试用例有自己的worksheet,注意第三个字符串,worksheet名后面的 // 美元符号“$” [DataSource( "System.Data.Odbc", @"Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=UsersTest.xls;DefaultDir=.", "LogOnTest$", DataAccessMethod.Sequential)] [TestMethod] public void LogOnTest() { var username = TestContext.DataRow["username"] as string; var password = TestContext.DataRow["password"] as string; TestLibrary.UserHelper.LogOn(username, password);
Assert.IsTrue(selenium.IsTextPresented(...)); } } |