简体   繁体   English

如何使用Tapestry 3对IMarkupWriter的内容进行单元测试?

[英]How can I unit test IMarkupWriter's content with Tapestry 3?

I'm working with an older project that is using tapestry 3, and I'd like to write tests for custom components. 我正在使用使用Tapestry 3的旧项目,我想为自定义组件编写测试。 Is there any way to test the content that has been written to the IMarkupWriter ? 有什么方法可以测试已写入IMarkupWriter

Tapestry seems to have made the implementation classes for this interface very untestable. Tapestry似乎使该接口的实现类非常不可测试。 Calling toString() on it simply returns Object.toString() . 对其调用toString()只会返回Object.toString()

Creating a subclass that creates a new toString() is impossible since they made all of the members private in their super-classes. 创建子类以创建新的toString()是不可能的,因为它们将所有成员都私有化为其超类。

Do I need to basically write an implementation of IMarkupWriter from scratch? 我是否需要从头开始编写IMarkupWriter的实现?

I would appreciate any assistance. 我将不胜感激。 Thanks! 谢谢!

Well, I would tend to favor the use of EasyMock for mocking an interface. 好吧,我倾向于使用EasyMock模拟接口。

However, when it comes to testing components, it's somewhat presumptuous to think you can unit test them in isolation and have any meaningful assurance that they will operate in production, since the components entirely exist to operate in concert with other components and the application as a whole: by definition, this means that meaningful tests are integration tests. 但是,当涉及到组件测试时,认为您可以孤立地对它们进行单元测试并确保它们将在生产环境中运行有任何有意义的保证,这有点冒昧,因为这些组件完全可以与其他组件和应用程序协同工作。整体:按照定义,这意味着有意义的测试是集成测试。 I recomment using Geb for integration testing. 我建议使用Geb进行集成测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM