词条 | TestNG |
释义 |
| name = TestNG | logo = | screenshot = | caption = | developer = Cédric Beust, the TestNG team | latest release version = 6.14.3[1] | latest release date = {{release date|2018|02|23}} | programming language = Java | operating system = Cross-platform | genre = Unit testing tool | license = Apache License 2.0[2] | website = {{URL|http://testng.org/}} }} TestNG is a testing framework for the Java programming language created by Cédric Beust and inspired by JUnit and NUnit. The design goal of TestNG is to cover a wider range of test categories: unit, functional, end-to-end, integration, etc., with more powerful and easy-to-use functionalities. FeaturesTestNG's main features include:
Data ProviderA data provider in TestNG is a method in a test class, which provides an array of varied actual values to dependent test methods. Example: The returned type of a data provider can be one of the following two types:
Tool SupportTestNG is supported, out-of-the-box or via plug-ins, by each of the three major Java IDEs - Eclipse, IntelliJ IDEA, and NetBeans. It also comes with a custom task for Apache Ant and is supported by the Maven build system. The Hudson continuous integration server has built-in support for TestNG and is able to track and chart test results over time. Most Java code coverage tools, such as Cobertura, work seamlessly with TestNG. ReportingTestNG generates test reports in HTML and XML formats. The XML output can be transformed by the Ant JUnitReport task[3] to generate reports similar to those obtained when using JUnit. Since version 4.6, TestNG also provides a reporter API[4] that permits third-party report generators, such as ReportNG,[5] PDFngreport[6] and TestNG-XSLT,[7] to be used. Comparison with JUnitThe differences between and respective advantages of the two seemingly competing Java tools, TestNG and JUnit, have been debated throughout the decade. Both camps have strong grounds and supporters. Stackoverflow discussions reflect this controversy.[8][9][10] AnnotationsIn JUnit 4, the @BeforeClass and @AfterClass methods have to be declared as static. TestNG does not have this constraint. TestNG has provided four additional setup/teardown pairs for the suite, test and groups, i.e. @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeGroup and @AfterGroup, @BeforeMethod and @AfterMethod. TestNG provide wide range of support to automate application using selenium. Parameterized testThis feature is implemented in both tools, however in quite different ways. TestNG has two ways for providing varying parameter values to a test method: by setting the testng.xml, and by defining a @DataProvider method. In JUnit 4, @RunWith and @Parameters are used together to facilitate parameterized tests, while the @Parameters method has to return List[] with all the actual values, which will be fed into a dedicated class constructor as an argument. ConclusionJUnit is often shipped with mainstream IDEs by default, which contributes to its wider popularity. However, TestNG's goal is much wider, which includes not only unit testing, but also support of integration and acceptance testing, etc. Which one is better or more suitable depends on use contexts and requirements. See also
References1. ^[https://github.com/cbeust/testng/releases|Project GitHub releases page] 2. ^{{cite web | url=http://testng.org/license/ | title=Apache License Version 2.0 | date=January 2004 | deadurl=yes | archiveurl=https://web.archive.org/web/20131221232410/http://testng.org/license/ | archivedate=2013-12-21 | df= }} 3. ^JUnitReport {{Webarchive|url=https://web.archive.org/web/20100224011201/http://ant.apache.org/manual/OptionalTasks/junitreport.html |date=2010-02-24 }} 4. ^Announcing TestNG 4.6 5. ^ReportNG 1.0 Final Released 6. ^[https://uttesh.github.io/pdfngreport/ PDFngreport 1.0.0] 7. ^[https://code.google.com/p/testng-xslt/ TestNG XSL Reports] 8. ^{{cite web|url=https://stackoverflow.com/questions/6658/junit-vs-testng |title=Junit vs TestNG |publisher=stackoverflow.com}} 9. ^{{cite web |url=https://stackoverflow.com/questions/3438785/junit-vs-testng |title=JUnit vs TestNG |publisher=stackoverflow.com |deadurl=yes |archiveurl=https://web.archive.org/web/20140202131938/http://stackoverflow.com/questions/3438785/junit-vs-testng |archivedate=2014-02-02 |df= }} 10. ^{{cite web|url=https://stackoverflow.com/questions/3411768/which-unittest-framework-to-learn-for-java-now |title=Which UnitTest framework to learn for Java now? |publisher=stackoverflow.com}} External links
3 : Unit testing frameworks|Java platform|Software using the Apache license |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。