在理解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的测试驱动开发
发布评论