ISTC Workshop Iulie 2015 – TestNG vs Junit: Exercises

  1. Create a simple test in Junit/TestNG. Make use of assertions.
  2. Create two tests that are using:
    1. Before/After in Junit
    2. BeforeMethod/AfterMethod in TestNG
  3. Create two tests that are using BeforeClass/AfterClass annotations in Junit/TestNG
  4. Create a group of tests:
    1. Using Categories in Junit
    2. Using Groups in TestNG
  5. Create a suite of tests using:
    1. Using @RunWith(Suite.class) and @Suite.SuiteClasses for Junit
    2. Using <suite> in testng.xml file for TestNG.
    3. For TestNG use @BeforeSuite and @AfterSuite annotations
  6. Create one test that is using timeouts:
    1. @Test(timeout = 1000) for JUnit
    2. @Test(timeOut = 2000) for TestNG
  7. Create one test that is:
    1. Ignored in Junit
    2. Disabled in TestNG
  8. Create one test that verifies expected exceptions:
    1. Using expected in Junit
    2. Using expectedExceptions in TestNG
  9. Create one dependency test for TestNG using dependsOnMethods
  10. Create parameterized tests:
    1. Using @Parameters and Parameterized.class in Junit
    2. Using @DataProvider in TestNG
  11. Create some tests and run them in parallel:
    1. Using ParallelRunner for JUnit
    2. Using parallel and thread-count suite attributes for TestNG
  12. Check the reports generated:
    1. XML file generated in Eclipse by Junit
    2. HTML file generated by TestNG

ISTC Workshop Iulie 2015 – TestNG vs Junit: Prerequisites

  1. For a fluent workshop please bring your laptop or make sure that at least your colleague comes with one and the following are installed on your machine:
    1. Eclipse - http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/marsr
    2. Java - Java SE Development Kit 7u79 can be downloaded from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
    3. Junit – this is already integrated in Eclipse
    4. TestNG – follow the steps provided here - http://howtodoinjava.com/2014/11/19/testng-tutorial-with-eclipse/#install_testng
  2. If you don’t want to install the above on your laptop please use this virtual machine which already has the setup done - https://www.dropbox.com/s/r8wzynie49ni1u5/ubuntu.vdi?dl=0
  3. Please make sure to arrive between 9:30 and 10:00 o’clock.
  4. Location: Ness Headquarters, Str. Palas 5B, UBC2, 5th floor

TestNG vs JUnit - In Depth Workshop on July 25th 2015

This new workshop provides an in-depth look to some of the most popular unit testing frameworks. Participants will learn about TestNG and JUnit frameworks and how to set them up with Java projects.

After this workshop you will be able to:

  • Get started with TestNG and JUnit
  • Setup and integrate them in your projects
  • Use best practices to improve the effectiveness and quality of your tests

Workshop contents:

  • What is JUnit
  • What is TestNG
  • Main differences
  • Advantages and disadvantages
  • Eclipse setup
  • Types of assertions
  • Creating and grouping tests
  • Combine tests in test suites
  • Parameterized tests
  • Parallel execution
  • Generate test reports

Join us to see which one best suits your needs!