直接对条纹验证注释进行单元测试
Stripes 允许您使用成员变量上的 @Validate 注释来验证表单输入值。有谁有直接测试这些注释的经验。我可以通过测试从 ActionBean 返回的验证错误来做到这一点,但这似乎有点冗长,我想要一种更直接的方法来测试输入值是否有效。
我对框架的内部结构还不太熟悉,我希望有人能给我一些从哪里开始的指导。 TIA。
Stripes allows you to validate your form input values using the @Validate annotation on your member variables. Does anyone have any experience testing these annotations directly. I could do this by testing the validation errors that come back from the ActionBean, but this seems a little long winded and I would like a more direct method of testing if an input value is valid.
I'm not that familiar with the innards of the Framework yet, and I was hoping someone could give me some direction on where to start. TIA.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用的一种方法是 Stripes 内置 模拟往返。它对于模拟容器外部操作 bean 事件的完整测试非常有用。
文档中的示例:
此外,您可以使用
trip.getValidationErrors()
并断言您的错误就在那里。One method I've used is Stripes' built in MockRoundtrip. It is useful for simulating a complete test of an action bean event outside the container.
Example from the documentation:
Additionally, you could use
trip.getValidationErrors()
and assert that your error is in there.