针对JSP的测试驱动开发 [英] Test-driven development for JSPs specifically

查看:63
本文介绍了针对JSP的测试驱动开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在理解TDD实际是什么之前,我一直在编写测试驱动的代码.在没有实现的情况下调用函数和类可以帮助我以更快,更高效的方式理解和构建应用程序.因此,我非常习惯编写代码->编译->看到它失败->通过构建其实现来修复它的过程.

I've been writing test-driven code even before understanding what TDD actually was. Calling functions and classes without having its implementation helps me understand and build my application in a much faster and efficient way. So I'm very used the process of writing code->compiling it->seeing it fail->fixing it by building its implementation.

对于Web来说,此过程有点困难.特别是JSP.当我编译Java类时,一切都很好,我可以看到编译错误.但是,如果看到JSP中的错误,则需要我打开浏览器并调用该特定的JSP.

This process is a bit harder for the Web. Specifically JSPs. When I compile my Java classes, all it's fine, I can see the compile errors. However seeing errors in the JSPs require me to open a browser and call that specific JSP.

有没有一种方法可以避免此过程并向我显示JSP编译错误而无需实际加载浏览器?

Is there a way to avoid this process and show me the JSP compile errors without actually loading up a browser?

推荐答案

我通常不直接测试JSP.通常,在您的JSP中保持尽可能少的逻辑是一个好主意,如果您的JSP仅包含几个<c:out>标记,则没有太多要测试的东西.但是,如果您确实有很多逻辑,那么我要做的就是将该逻辑提取到自定义标签中,您可以轻松地测试驱动器.

I typically don't test JSPs directly. It's generally a good idea to keep as little logic in your JSPs as possible, and if you're JSPs only contain a few <c:out> tags then there's not really too much to test. However, if you do have a fair amount of logic within them then what I would do is extract that logic into a custom tag, which you can test drive pretty easily.

这篇关于针对JSP的测试驱动开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆