减少编写集成和系统测试的痛苦

发布于 2024-08-30 06:45:00 字数 206 浏览 8 评论 0原文

我想为我的应用程序进行集成测试和系统测试,但是进行良好的集成和系统测试通常需要付出很多努力,所以我没有费心。我尝试了几次,编写了自定义的、特定于应用程序的测试工具,每次都感觉像是重新发明轮子。我想知道这是否是错误的做法。是否有集成和完整系统测试的“标准”方法?

编辑:澄清一下,它是针对桌面和 Web 应用程序的自动化测试。理想情况下,一个完整的测试套件可以测试应用程序的全部功能。

I would like to make integration tests and system tests for my applications but producing good integration and system tests have often needed so much effort that I have not bothered. The few times I tried, I wrote custom, application-specific test harnesses, which felt like re-inventing the wheel each time. I wonder if this is the wrong approach. Is there a "standard" approach to integration and full system testing?

EDIT: To clarify, it's automated tests, for desktop and web applications. Ideally a complete test suite that exercises the full functionality of the application.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遗弃M 2024-09-06 06:45:00

如果“进行集成测试和系统测试”是指自动化测试,那么答案是否定的,没有标准方法。选择什么方法取决于:

  • 应用程序的特征(例如,它是否有 GUI?,它是只读的吗?,它有多少外部依赖项,等等)
  • 您要测试的内容(也许您只需要 GUI 测试,或者也许恰恰相反,您并不真正关心 GUI,但内部逻辑很关键)
  • 您希望多快看到结果(例如,您存根的越多,测试变得越快)
  • 您团队的技能组

就我个人而言,我喜欢任何与 JUnit 集成的方法。 JUnit 是一个非常棒的框架,它得到了很好的支持,并且可以轻松地绑定到连续集成服务器中。以下是一些可能的方法:

  • Selenium 与 JUnit - 用于驱动 Web 应用程序的神奇工具
  • Concordion - 适用于所有应用程序类型。与 JUnit 集成并允许使用简单的英语规范进行测试。您的“夹具”/测试代码将挂钩规范中的关键字并对其进行断言或执行操作。
  • FEST - 对于 swing 应用程序,它再次与 JUnit 集成(看到主题了吗?;) (更多选择此处

上述示例提供了大量的用于测试的框帮助。当然,它们仍然需要努力连接到您的应用程序并进行维护,但其优点是非常值得的。除了上述内容之外,您可能还需要考虑如何存根或模拟应用程序的区域。也许您想在“GUI 下”或“数据库之上”进行所有测试。在第一种情况下,您需要从代码中 GUI 与其交互的点开始测试,而在后一种情况下,您需要删除与数据库交互的服务。

重点是,有很多方法可以做到这一点。最好首先清楚地了解您想要从测试中获得什么。然后根据您想要测试的内容了解现有的框架可以帮助您,最后,不要试图在一夜之间征服世界。从小处开始,运行一些测试。获得绿色条(总是很高兴看到!)获得经过验证的稳定平台进行测试并确保您对此感到满意。然后随着你的进展添加更多。

If by "make integration tests and system tests" you mean automated tests, then the answer is no, there is no standard approach. What approach choose will depend on:

  • the characteristics of the application (e.g. does it have a GUI?, is it read only?, how many external dependencies does it have, etc)
  • what you are trying to test (maybe you only need GUI tests, or perhaps the opposite is true and you don't really care about the GUI but the internal logic is critical)
  • how quickly you want to see the results (e.g. the more you stub out the faster your tests become)
  • the skillsets on your team

Personally, I love any approach that integrates with JUnit. JUnit is a fantastic framework which is well supported and easily tied into a continuous intergration server. Here are a few possible approaches:

  • Selenium with JUnit - Fantastic tool for driving web applications
  • Concordion - for all application types. Integrates with JUnit and allows plain english specifications of tests. Your 'fixture'/test code will hook into key words in the specification and assert or perform actions on them.
  • FEST - for swing applications, again it integrates with JUnit (see a theme yet? ;) (more choices here)

The above examples provide a tremendous amount of out of the box help for testing. Of course, they still require effort to wire to your application and maintain, but the advantages are well worth it. In addition to the above, you may need to be thinking about how to stub or mock out areas of your application. Perhaps you want to do all of your testing "under the GUI" or "above the database". In the first scenario, you'll need your tests to start at the points in your code where the GUI would interact with it and in the latter you'll need to stub out the services which interact with your database.

Point being, there's lots of ways to do this. Best start with a very clear understanding of what you want to get out of your testing. Then learn what existing frameworks are out there to help you based on what you want to test, and finally, don't try to conquer the world in a night. Start small getting a few tests running. Get the green bar (always a joy to see!) Get a stable proven platform for testing and make sure you're happy with it. Then add more as you go along.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文