O'Reilly logo

TestNg Beginner's Guide by Varun Menon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – unit testing with TestNG

  1. Create a new Java Project named SimpleUnitTestProject in Eclipse with the folder structure shown in the following screenshot:
    Time for action – unit testing with TestNG
  2. Open the file ListUnitTest.java and add the following snippet to it:
    package org.test.sampletests; import java.util.ArrayList; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class ListUnitTest { ArrayList<String> listObj = new ArrayList<String>(); @BeforeClass public void beforeClass(){ listObj.add("Sample-0"); listObj.add("Sample-1"); listObj.add("Sample-2"); } @Test public void verifyDataBasedOnIndex(){ String data ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required