如何为VSTO C#编写的EXCEL插件编写单元测试?

发布于 2025-01-16 22:01:28 字数 224 浏览 3 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮云落日 2025-01-23 22:01:28

最直接、最简单的解决方案是自动化 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文