是否可以在 mstest 中进行工厂测试,就像在 MbUnit 中一样?
我们公司使用 mstest 进行单元测试。 主要原因是 MbUnit 没有免费的 Visual Studio 集成(TestDriven.NET 对公司来说不是免费的)。
最近,我偶然发现需要在同一接口的两个不同实现上运行相同的单元测试。 根据我过去的经验,我知道使用 MbUnit 很容易做到。 但是,如何使用 MSTest 做到这一点呢?
我强调一点,我需要为每个接口提供单独的结果,因此,请不要提供类似从相同的单元测试方法运行相同的方法两次(每个接口一次)的操作,因为这样做只会产生一个结果。
我知道数据驱动的解决方案并正在使用它,但这是一个痛苦的问题。 有没有更简单的方法,即 MbUnit 方法?
谢谢。
We are using mstest for unit tests at our company. The main reason is that there is no free Visual Studio integration for MbUnit (TestDriven.NET is not free for companies).
Recently, I have stumbled upon a need to run the same unit tests on two different implementations of the same interface. From my past experience I know it is easy to do with MbUnit. But, how to do it with MSTest?
I stress the point that I need separate results for each interface, so, please, do not offer things like running the same method twice - once per interface - from the same unit test method, because doing so yields only one result.
I am aware of the data driven solution and using it now, but it is a pain in the a*s. Is there an easier way, the MbUnit way?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除了使用 MSTest 的数据驱动测试功能之外,我不知道还有什么优雅的方法可以做到这一点。 然而,您可以尝试为您的测试装置使用一个抽象基类,然后为每个要测试的接口创建它的一个子类。
顺便说一句,Gallio 提供与 Visual Studio 测试工具的免费集成。 我们还将继续开发另一个 Visual Studio 插件,作为 Gallio v3.2 的一部分。
I don't know of an elegant way to do this in MSTest besides using its data-driven testing features. However, you might try using an abstract base class for your test fixture and then creating one subclass of it for each interface to be tested.
BTW, Gallio provides free integration with the Visual Studio test tools. We're also going to resume work on another add-in for Visual Studio as part of Gallio v3.2.