TestNG - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

TestNG

Description:

Started out in 2004 of frustration with some Junit 3.8 deficiencies ... http://www.youtube.com/watch?v=TtcEpryRy44. http://www.artima.com/lejava/articles/testng.html ... – PowerPoint PPT presentation

Number of Views:211
Avg rating:5.0/5.0
Slides: 15
Provided by: Them161
Category:

less

Transcript and Presenter's Notes

Title: TestNG


1
  • TestNG
  • Nest generation Java Testing

Bojana Kolbah Siyuan He
Licensed under a Creative Commons Attribution 3.0
License
2
Outline
1. Introduction and overview
2. Installation
3. Demo and comparison between TestNG and
JUnit 4
4. TestNG open source community
5. References and questions
3
TestNG overview
  • Author Cédric Beust
  • http//testng.org
  • Started out in 2004 of frustration with some
    Junit 3.8 deficiencies
  • JUnit set-up and tear-down are run for each test
  • JUnit is intended for unit testing

4
TestNG overview
  • Inspired by JUnit but introduces some new
    functionalities that make it more powerful and
    easier to use
  • Benefits of using TestNG increase for testing
    that goes over and above unit testing (e.g.
    integration testing, system testing)
  • Licensed under Apache license

5
Installation Guidelines
  • Generic package (Command line, Ant, Maven, IDEA)
  • Download the package
  • Update classpath
  • Eclipse plug-in
  • Add site http//beust.com/eclipse to Software
    Updates GUI in Eclipse and run an update
  • Click on Install, accept the license and reboot
    Eclipse
  • Or download directly into the plug-in directory

6
Comparison
  • JUnit 4
  • Test Configuration is less and no XML file
    configuration at all.Less configuration makes it
    more easy and really fast to create
  • Similar in JUnit, but less powerful._at_After/Before
    works in methods and _at_After/BeforeClass will
    work with classes.
  • TestNG
  • Flexible test configuration in an external XML
    file. External configuration gives more
    flexibility.
  • flexible fixture _at_After/BeforeSuite._at_After/Befor
    eGroup._at_After/BeforeClass._at_After/BeforeMethod

7
Comparison(Cont.)
  • TestNG
  • Group testing. Here we can create Groups.
  • Include, exclude, group at different level,
    partial groupetc.
  • _at_ParametersSupport for parameters using
  • _at_DataProviderSupport for data-driven testing
    .(code example?)
  • JUnit 4
  • _at_RunWith(Suite.class) Less flexible.
  • No such type of annotations
  • Integrate with EasyMock for Mock object testing

8
Comparison (Cont.)
  • TestNG
  • Option to run failed tests only/ last test only
    in the IDE(generate a new test suite in
    testng-failed.xml)
  • Using ExpectedExceptions in _at_Test Annotation we
    can expect some exceptions in the test methods
    and thus the method will be success.
  • JUnit 4
  • We have to select and run each methods which are
    failed
  • We can use (expected Exception.class) in the
    _at_Test annotation

9
Comparison(Cont. )
  • TestNG
  • Allows distribution of tests on slave machines.
  • Parallel running
  • Embeds BeanShell (scripting)  for further
    flexibility.
  • Dependent Methods
  • JUnit 4
  • N/A
  • Supported by plug-ins. ( e.g. parallel-junit )
  • JUnit dont have this feature at all.
  • N/Abasic princeple of unit testing is that test
    methods should be independent of each other

10
Comparison (cont.)
  • TestNG
  • Extension/Integrating with other tools (Spring,
    Maven, Tapestry, Stripes, Groovy, JMockit, Using
    JUnit Extensions!!!)
  • Logging support
  • JUnit4
  • Cant defeat JUnit in this matter. It has a lot of
    supporting tools and plugins.
  • Not logging support in JUnit.

11
Comparison(Cont. 5)
  • JUnit 4
  • _at_Ignore annotation is there for ignoring a test
    method.
  • TestNG
  • No annotation like _at_Ignore. But we can ignore
    through exclusion of groups.
  • TestNG Beats JUnit 4.

12
TestNG in Open Source community
  • TestNG webpage contains documentation and
    articles of interest
  • There are two on-line forums and a email
    mailing-list on Google Groups
  • No need for training or professional services
  • Eight developers are credited as main
    contributors and another 11 as ideas and
    suggestions suppliers
  • Beust wrote a book Next Generation Java Testing
  • Book Java Power Tools has a chapter on testNG
  • There is no obvious invitation for contributors

13
  • don't let the tool(JUnit) you use restrict your
    creativity
  • Lets Try TestNG
  • http//www.youtube.com/watch?vTtcEpryRy44
  • http//www.artima.com/lejava/articles/testng.html

14
References
  • 1 TestNG web page http//testng.org/doc/index.ht
    ml
  • 2In pursuit of code quality JUnit 4 vs.TestNG
    http//www-128.ibm.com/developerworks/java/library
    /j-cq08296/index.html
  • 3 Beyond JUnitIntroducingTestNG,
    http//www.theserverside.com/tt/articles/content/J
    IApresentations/Beust.pdf
  • 4 TestNG 5.6 and Junit 4.4 which framework
    you will choose for unit testing?
    http//lijinjoseji.wordpress.com/2008/02/29/testng
    -56-and-junit-44-which-framework-you-will-choose-f
    or-unit-testing/
Write a Comment
User Comments (0)
About PowerShow.com