TestNG Project Setup in Visual Studio Code Part-1
- pavithrasenthurai
- Dec 15, 2024
- 5 min read
Updated: Dec 31, 2024

TestNG (Test Next Generation) is a testing framework inspired by JUnit and NUnit with its own functionalities and categories of tests such as unit, functional, end-to-end ,integration etc.
Test Configurations in TestNG allows flexible test configurations such as grouping tests, running tests in parallel, and parameterizing tests. We can validate the test results using Assertions. It is possible to approach Data-Driven Testing in TestNG to run the same test with multiple sets of data. Integration can be done easily with build tools like Maven and Gradle, and CI tools like Jenkins, Bamboo, CircleCI, Git Actions etc.
Test Driven Development (TDD) allows clear communication between developers and testers. Selenium and Java enables automation of web application tests while maintaining a readable code.
VS-Code is a light weight development tool which is easy to learn and use. To create the TestNG framework using VS-Code, we should have a knowledge of VS Code and its Git functionalities. This blog helps in understanding the Selenium TestNG TDD Project which covers the step by step process starting from setting up the repository and pushing the project to GitHub using basic commands and developing in vs code along with basic git commands.
Installing Extensions
VS Code extensions enhances the functionality of the VS Code editor and customizes the workflow and suits the needs of the project for development and test environment. It adds new features, provides language support and integrates with external tools etc.

Creating a Maven Project
We can create a maven project using following command from the PowerShell in windows
Navigate to a folder where you like to create a maven project
Right click on the folder to launch the command prompt or a PowerShell
Execute the following command from the Prompt
Once executed get into the folder using "cd blog-testng-demo" command and execute "Code ." to launch the VS-Code
mvn archetype:generate -DgroupId="com.NumpyNinja" -DartifactId="blog-testng-demo" -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
cd blogTestngBDD
code .We can also create a maven project using VS-Code
Launch VS-Code and follow the screenshot to create a maven project

Method 1: Click on the + on Maven Section to create the new maven project 
Method 2: use Ctrl+Shift+P to open the command search and start typing maven
Enter the information required for maven project as shown below








Backup and Sync Settings
Backup and Sync settings is crucial to maintain a consistent developing environment across various machines. It allows extensions, snippets, key bindings, UI state and other configurations to be synced through built-in setting sync feature. This feature uses your GitHub or Microsoft account to securely store the settings.




Git Functionality in VS Code
You can use the integrated Git features available in Visual Studio Code or Git commands can be executed directly from the command prompt.



Visual Studio Code Shortcuts
Shortcuts are essential and effective way to interact with the system. It helps Developers and Testers to perform the code scripts and actions quickly without clicking through the menus. It speeds up their process and enhances productivity.
Git Features

The features will pop up as the screenshot depicts above and you can perform the features accordingly.
GitHub Copilot/Copilot Chat
As you see, we have installed GitHub Copilot and GitHub Copilot-chat in the VS-Code extensions. GitHub Copilot is a paid service which effectively detects the syntax and code errors and suggests the corrected ones. If you encounter an error in your code, you mouse over on the code, it will suggest you options to choose whether you can make a correction with a suggested explanation or you can just click "fix using copilot" and it will fix your errors but always confirm the solution.
GitHub Copilot Chat is a conversation space where you can raise your queries and get answers. You can also copy your complex codes or scripts and paste it in the chat to get the line by line explanation by reading your given codes.
This blog will be continued in https://www.numpyninja.com/post/selenium-testng-tdd-framework-in-visual-studio-code

