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