如何为VSTO C#编写的EXCEL插件编写单元测试?
我有一个 Excel 插件,运行得非常完美。它的作用是用户从 Excel 工作表中提供一些输入,插件后端从 API 获取数据并更新 Excel 列。一切对我来说都很好。
现在,我想为其编写一些单元测试。我已经使用起订量和其他框架为其他项目编写了几十个测试,但没有找到编写单元测试的方法。
此外,插件还会读取 Excel 行。我在测试中该如何应对? 然后插件更新 Excel 行。我如何在测试中处理这个罐子?
I have a excel plug-in that is working very perfectly. What it does is it the user give some input from excel sheet and the plug-in backend gets the data from API and update the excel columns. Everything is working fine for me.
Now, I want to write some unit test for it. I have written dozen of test for other projects using moq and other framework but did not find a way to wirte unit test.
Also, the plugin-In reads excel rows. How I can handle in test?
Plug-in then update the excel rows. How I can handle this canse in test?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最直接、最简单的解决方案是自动化 Excel,这样您就可以获取真正的 Excel 对象并进行修改。
在某些情况下,您可以模拟 Excel 对象而不是真实对象。
阅读有关 Visual Studio 中单元测试的更多信息 对您的代码进行单元测试 MSDN 部分。
The most straightforward and easiest solution is to automate Excel, so you could grab real Excel objects and do the modifications.
In some cases you can mock Excel objects instead of real ones.
Read more about unit testing in Visual Studio in the Unit Test Your Code section of MSDN.