Java 中的功能测试

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7961648/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 22:13:26  来源:igfitidea点击:

Functional Testing in Java

javatestingjunitintegration-testing

提问by Bat_Programmer

I believe functional testing is testing of two or more modules together with the intent of finding defects, demonstrating that defects are not present, and verifying that the module performs its intended functions.

Is there any functional testing tool for java applications? I'm in need to do this. I know of junit which I have used in unit testing and also T2 utility which is an extension of junit, which I have used for automated testing. Is there any particular framework or tool for functional testing?

我相信功能测试是对两个或多个模块进行测试,目的是发现缺陷,证明不存在缺陷,并验证模块执行其预期功能。

有没有针对java应用的功能测试工具?我需要这样做。我知道我在单元测试中使用过的 junit 以及作为 junit 的扩展的 T2 实用程序,我曾将其用于自动化测试。是否有用于功能测试的特定框架或工具?

采纳答案by Cedric Beust

JUnit is more aimed at unit testing. For functional testing, take a look at TestNG, which offers advanced functional testing features such as:

JUnit 更针对单元测试。对于功能测试,请查看TestNG,它提供了高级功能测试功能,例如:

  • Groups.
  • Testing multithreaded code.
  • Runs in parallel.
  • Dependencies.
  • Suite-level configurations.
  • Dependency injection (Guice).
  • 团体。
  • 测试多线程代码。
  • 并行运行。
  • 依赖性。
  • 套件级配置。
  • 依赖注入(Guice)。

回答by user85

With introduction of Junit4, you can do functional testing of Java using Junit as well. The latest junit 4 version (junit 4.11) comes with some very good features like parametrization, annonation support and annonations like @Ignore, exception test support, suite configuration, etc.
But off-course you'll have to do little bit modification to handle the default fatal behavior of assertions. You can refer http://apitestingwithjunit.blogspot.in/on how to achieve this (don't worry it is very simple).

随着 Junit4 的引入,您也可以使用 Junit 对 Java 进行功能测试。最新的 junit 4 版本 (junit 4.11) 带有一些非常好的特性,例如参数化、注释支持和注释(如@Ignore、异常测试支持、套件配置等)。
但是,当然你必须做一些修改才能处理断言的默认致命行为。您可以参考http://apitestingwithjunit.blogspot.in/了解如何实现这一点(别担心,这很简单)。

回答by Dave Newton

Largely the same sets of tools, although how you test might be a little different.

基本上相同的工具集,尽管您的测试方式可能略有不同。

I consider a lot of functional and integration testing to be sort-of the same thing. As such I'll use more BDD-oriented tools, like easybor JBehaveinstead of "raw" JUnit or TestNG.

我认为很多功能测试和集成测试都差不多。因此,我将使用更多面向 BDD 的工具,例如easybJBehave,而不是“原始”JUnit 或 TestNG。

Depending on what functionality you're testing, mocking libraries like mockitoor powermockare handy, although perhaps not as much as with "pure" unit testing.

根据您要测试的功能,mockitopowermock 之类的模拟库很方便,尽管可能不如“纯”单元测试那么多。