开发者

Unit Testing VS 2008 Using Excel

开发者 https://www.devze.com 2022-12-28 17:08 出处:网络
When using Excel (2003) to provide data for my unit tests it seems to think that when a cell has TRUE / FALSE value that it is null when there has been no preceding cell values e.g.

When using Excel (2003) to provide data for my unit tests it seems to think that when a cell has TRUE / FALSE value that it is null when there has been no preceding cell values e.g.

 if (TestContext.DataRow["SatisfactionExtremelySatisfied"] != DBNull.Value)
      model.SatisfactionExtremelySatisfied开发者_开发技巧 = (bool)TestContext.DataRow
      ["SatisfactionExtremelySatisfied"];

Sample Excel Data

DataRow  SatisfactionExtremelySatisfied
0
1
2                 TRUE
3                 TRUE

When reading the test data using OLEDB the cells with TRUE hold no value (when inspected in debug) but when the preceding cells have the value FALSE entered it correctly gets the values TRUE.

Am I missing something?


Simplify.

Save the excel spreadsheet as a plain text .csv file, and have your test framework read that. Otherwise, you're complicating your tests by troubleshooting the nuances of reading from Excel.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号