- In the Project tool window, right click the directory where you want to create a new test class.
- Select New | Java Class from the context menu.
- In the Create New Class dialog, specify the class name and click OK.
-
In the editor, write the code for your test class. Use the TestNG annotations where necessary.
For example, you may want to annotate the whole class or individual methods:
@Test ()public class NewClassForTesting {} @DataProviderpublic Object[][] data(){ return new String[][]{ new String[]{"data1"}, new String[]{"data2"} }; } @Test(dataProvider = "data") public void test(String d ){ Assert.assertEquals("First Line\nSecond Line", "Third Line\nFourth Line");}
If the annotation you add lacks the import statement, the corresponding intention action will suggest you to create one:


