在现有的大型Java代码库中构建测试套件 [英] Building a test suite in a large existing Java code base

查看:104
本文介绍了在现有的大型Java代码库中构建测试套件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有大约10年的现有代码库的Web应用程序进行工作,有大约1000个类文件和大约100,000行代码.好消息是代码组织得很好,业务逻辑与控制器域分开,并且具有高度的可重用性.坏消息是,只有测试套件(JUnit)才刚刚开始.最多最多可以进行十二打测试.

I am working on a web application with an existing code base that has probably been around for 10 years, there are ~1000 class files and ~100,000 lines of code. The good news is that the code is organized well, business logic is separate from the controller domain, and there is a high level of reusability. The bad news is there is only the very beginnings of a test suite (JUnit); there's maybe 12 dozen tests at most.

代码通常是为企业Java项目组织的.有一个类似stuts的控制器程序包,该模型几乎由纯粹的数据对象组成,有一个像休眠层一样的数据库层,它很大程度上封装在数据访问对象中,还有一些简单,自包含且合乎逻辑的服务程序包.构建此测试套件的最终目标是朝着持续的集成开发过程发展.

The code is organized fairly typically for an enterprise Java project. There is a stuts-esque controller package, the model consists of almost purely data objects, there is a hibernate like database layer that is largely encapsulated within data access objects, and a handful of service packages that are simple, self contained, and logical. The end goal of building this test suite is to move towards a continuous integration development process.

  • 您将如何为此类应用程序构建测试套件?
  • 您将使用哪些工具简化流程?

欢迎提出任何建议.谢谢!

Any suggestions welcome. thanks!

推荐答案

首先阅读此处).接下来,我将编写一些端到端烟雾测试,以涵盖最常见的用例.以下是有关处理方法的一些想法: http://simpleprogrammer.com/getting-最新蝙蝠系列/

Start by reading Working Effectively with Legacy Code (short version here). Next I would write a couple of end-to-end smoke tests to cover the most common use cases. Here are some ideas on how to approach it: http://simpleprogrammer.com/getting-up-to-bat-series/

然后,当我需要更改系统的某些部分时,我将进行有针对性的单元测试(请参阅上述书),然后进行更改.系统将逐渐被覆盖,或者至少是变化最频繁的部分,将被更好地覆盖,并且使用它会变得更加容易.

Then when I need to change some part of the system, I would cover it with focused unit tests (refer to the aforementioned book) and then do the change. Little by little the system - or at least the parts which change the most often - would be better covered and working with it would become easier.

这篇关于在现有的大型Java代码库中构建测试套件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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