How to create a TestNG file in IntelliJ IDE?


TestNG file is a simple java class. IntelliJ supports TestNG class as simple java class. To create a TestNG class, user should create a java class first and then enter the desired TestNG annotations and respective code to execute.

In this article, let’s follow the steps to create a TestNG file in IntelliJ.

Approach/Algorithm to solve this problem

  • Step 1: Go to the project where TestNG file needs to create.

  • Step 2: Select a folder where to create a TestNG file either in src or test folder. We will create the file in src folder in this article.

  • Step 3: Right click on the folder and select New −> Java Class as shown in below screenshot.

  • Step 4: A pop−up opens. Enter the file name and select as Class as shown in below screenshot.

  • Step 5: Press Enter after writing the name as NewTestngClass.

  • Step 6: User can see the file added in left side Project structure under src as well as in editor.

Below screenshots describe how to validate whether new class is added or not:

  • Step 7: User can add the required annotations and respective code to execute as shown in below screenshot.

Updated on: 16-Aug-2023

403 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements