针对JSP的测试驱动开发

编程入门 行业动态 更新时间:2024-10-10 00:20:59
本文介绍了针对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的测试驱动开发

本文发布于:2023-11-23 07:28:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620604.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:测试   JSP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!