NUnit 以编程方式与 spring 集成
我设计了一个基于组件的架构框架,并使用 NUnit 进行隔离测试 - 到目前为止还可以。
现在我想启用集成测试。因此,测试使用现有组件的真实实现。
组件的每个元素都有一个生命周期(初始化、启动和停止),我创建了一个 NUnit 组件。在开始部分,NUnit 的控制台运行程序将被执行。
好的 - 现在,如果我的 dll 中的执行路径中有一个测试装置类,那么运行程序会执行它们 - 很好!
但是:这至关重要!到目前为止,每个要测试的实现都存在于流程中,我想使用这个实例进行测试。如果我以当前方式使用 NUnit 运行程序,每个实例将被创建两次 - 最重要的是:我有一个 spring 容器和一个实现注册表。通过这个注册表,我可以访问进程中的所有实例。但是如何让测试装置访问现有注册表呢?
好:我可以在 nunit 运行程序的启动中启动组件架构框架 - 但这不是我想要的。
我的指南是 apache Cactus 框架(带有 JUnit 和 tomcat、JBoss 等)
有人可以帮忙吗?
多谢!
I have a component based architecture framework designed and I use NUnit for isolated testing - okay so far.
Now I want to enable integration tests. Therefore the tests use real implementations of the existing components.
Each element of the component has a life cycle (init, start and stop) and I created a NUnit component. In the start section the Console runner of the NUnit will be executed.
Okay - now if I have a test fixture class in my dlls in the execution path the runner exectues them - fine!
But: And this is crucial! Each to be tested implementation exists so far in the process and I want to use this instances for testing. If I use NUnit runner in the current way each instance will be created twice - and above all: I have a spring container and a implementation registry. Via this registry I can get access to all instances in the processes. But how do I give the test fixture access to the existing registry?
Good: I can start the component architecture framework in the startup of the nunit runner - but this is not what I want.
My guide is the apache Cactus framework (with JUnit and tomcat, JBoss etc.)
Can someone help?
Thanks a lot!
Check: http://cone.codeplex.com
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否考虑过使用 spring.net 的集成测试支持?它可以管理上下文,将对象注入到测试中,甚至回滚作为测试一部分启动的数据库事务。默认情况下,您的配置在夹具内的测试中重复使用。
Have you thought about using spring.net's integration testing support? It can manage contexts, inject objects into your tests and even rollback database transactions started as part of a test. By default your configuration is reused across tests within a fixture.