从外部应用程序测试 .Net C# WPF MVVM 应用程序

发布于 2024-09-12 16:45:09 字数 611 浏览 3 评论 0原文

我有一个使用 MVVM 的大型应用程序。该模型主要位于 C++ DLL 中。 ViewModel 采用 C# 语言,并且我已以通常的方式将 WPF 控件绑定到 ViewModel。

该应用程序已准备好进行集成测试。我可以从应用程序内部驱动测试,但我想将测试转移到另一个进程中,这样我就可以最大限度地减少测试内容对应用程序的污染。

我想用 C# 和 WPF 自己编写测试应用程序,但我对如何去做有点困惑。

注意:如果有第三方测试应用程序用于在 .Net 应用程序中测试 ViewModel,我也很想听听!

我想 Process.Start 是最初的进入方式,但从那里我迷失了。

基本上我需要让应用程序正常加载,像往常一样创建其模型,然后启动 GUI,因此我无法单独驱动单个方法(单元测试样式)。然后我想设置和获取我的 ViewModel 属性,就像我当前在本地测试中所做的那样。

我看过 James McCafferey 的关于测试 WPF 应用程序的 MSDN 03/09 文章,但它旨在测试 GUI(基本上是远程按下按钮等),这是我想摆脱的。

反思是这里的出路吗?如果是这样,请记住我不能简单地反映到“空”ViewModel,它必须连接到我的模型才能测试 VM 属性。

提前致谢

I have a largish application that uses MVVM. The Model is mostly in a C++ DLL. The ViewModel is in C#, and I've tied my WPF controls to the ViewModel in the usual way.

The app is ready for integration testing. I can drive tests from within the application, but I'd like to move testing out into another process so I can minimize polluting the application with test stuff.

I'd like to write the test application myself in C# and WPF, but I'm a bit stuck as how to go about it.

Note: If there's a third party testing application for testing ViewModels inside a .Net application, I'd love to hear about that too!

I imagine Process.Start is the initial way in, but from there I'm lost.

Basically I need to let the application load up normally, create its Model as usual, and start the GUI, so I can't drive individual methods in isolation (unit test style). Then I would like to set and get my ViewModel properties as I do currently with my local tests.

I've looked at James McCafferey's MSDN 03/09 article on testing WPF apps, but it's geared towards testing the GUI (basically remotely pressing Buttons etc), something I want to get away from.

Is reflection the way in here? If so, how, bearing in mind I can't simply reflect onto an 'empty' ViewModel, it has to be connected to my Model for the VM properties to be testable.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

爱她像谁 2024-09-19 16:45:09

基本上,我需要让应用程序正常加载,像往常一样创建其模型,然后启动 GUI,因此我无法单独驱动各个方法(单元测试样式)。

IcuTest (http://IcuTest.com/) 就是您正在寻找的。它允许您在单元测试框架中启动应用程序,并让您与模型和方法进行交互。

Basically I need to let the application load up normally, create its Model as usual, and start the GUI, so I can't drive individual methods in isolation (unit test style).

IcuTest (http://IcuTest.com/) is what you're looking for. It let's you start the app in a unit testing framework AND let's you interact with your Models and methods.

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