VS Team Test: .Net Unit Testing with Excel as Data Source: Adapter Failed

后端 未结 3 648
独厮守ぢ
独厮守ぢ 2020-12-18 08:10

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

3条回答
  •  清歌不尽
    2020-12-18 08:36

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

    App.Config

    
    
    
    
    
    

    For VS 2010, TestTools version used is Version=10.0.0.0

提交回复
热议问题