I've got similar problem. The reason for that was "Scope" option of "testng" dependency set to "test" when "compile" was needed.

How I fixed it (note, I used Eclipse):

  1. Open pom.xml file.
  2. Go to "Dependencies" tab.
  3. Select "testng" package and click on "Properties..."
  4. On opened screen change "Scope" option to "compile" and click "OK" to save it.
  5. Try to build your project again with "compile test" goals.
Answer from Pavik on Stack Overflow
🌐
Maven Repository
mvnrepository.com › artifact › org.testng › testng
Maven Repository: org.testng » testng
January 22, 2026 - TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more ... Links · Testing · Mocking · Maven Plugins · Testing · Android Packages · Language Runtime · JVM Languages · Logging Frameworks · JSON Libraries · Java Specifications · Core Utilities · Annotation Libraries · Mocking · Web Assets · HTTP Clients · Logging Bridges · Dependency Injection ·
🌐
Apache Maven
maven.apache.org › surefire › maven-surefire-plugin › examples › testng.html
Using TestNG – Maven Surefire Plugin
February 18, 2026 - <dependencies> [...] <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.9.4</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.2</version> <scope>test</scope> </dependency> [...] </dependencies> You may want to run two providers, e.g. surefire-junit47 and surefire-testng, and avoid running JUnit tests within surefire-testng provider by setting property junit=false (note that this property is not applicable if you configure the suiteXmlFiles parameter). <plugins> [...] <plugin> <groupI
🌐
TestNG
testng.org › maven
Using TestNG with Maven
<dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>7.5.1</version> <scope>test</scope> </dependency>
🌐
Maven Central
central.sonatype.com › artifact › org.testng › testng
Maven Central: org.testng:testng
<dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>7.12.0</version> </dependency> Copy to clipboard · <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <!-- This module was also published with a richer model, Gradle metadata, --> <!-- which should be used instead.
🌐
Christopher Siu
users.csc.calpoly.edu › ~gfisher › classes › 309 › lib › testng › doc › maven.html
TestNG - Maven
<dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.8</version> <scope>test</scope> </dependency> A sample surefire report with TestNG can be found here. Martin Gilday has added a new archetype for Maven2: to create a project using the archetype you simply have to specify my repository and the archetype ID.
Find elsewhere
🌐
Medium
medium.com › ai-qa-nexus › integrating-testng-with-maven-a-comprehensive-guide-on-what-testng-is-and-its-benefits-cc7fb9664b2c
Integrating TestNG with Maven: A Comprehensive Guide on What TestNG Is and Its Benefits | by Suresh Madhusanka Rodrigo | AI & QA Nexus | Medium
September 8, 2024 - TestNG is a testing framework inspired by JUnit and NUnit, designed to cover a wide range of test categories, including unit, functional, end-to-end, and integration testing. Navigate to your Maven project’s root directory and open the pom.xml ...
🌐
Maven Repository
mvnrepository.com › artifact › com.aventstack › chaintest-testng
Maven Repository: com.aventstack » chaintest-testng
March 29, 2025 - Maven Plugins · Testing · Android Packages · Language Runtime · JVM Languages · Logging Frameworks · JSON Libraries · Java Specifications · Core Utilities · Mocking · Annotation Libraries · Web Assets · HTTP Clients · Logging Bridges · Dependency Injection · XML Processing · Concurrency Libraries · Web Frameworks · Android Platform · Code Generators · View All · Home » com.aventstack » chaintest-testng ·
🌐
TestNG
testng.org › testng-eclipse
Eclipse plug-in | testng-eclipse
The (optional) TestNG M2E Integration plug-in was introduced in 6.9.10. It allows you to run your tests with System Properties or JVM settings, which are defined by maven-surefire-plugin or maven-failsafe-plugin of pom.xml, to be appended to the runtime TestNG process.
🌐
Medium
isuruuy.medium.com › learn-maven-testng-and-selenium-3b4952cb4479
Learn Maven, TestNG, and Selenium | by Isuru Uyanage | Medium
November 21, 2020 - You can go to the maven central repository, search for selenium java, and select the version. Select it and can copy the maven value. Similarly, you can get the testng dependency as well.
🌐
Medium
medium.com › test-automation-hub › getting-started-with-testng-2bf64521a12c
Getting started with TestNG. TestNG is an automation testing… | by Manul Wickramanayaka | Test Automation Hub | Medium
June 6, 2021 - Select the help tab, go to Eclipse Marketplace and search for TestNG for Eclipse. You will see the plugin and just install it. Create a maven project and let's name it “SeleniumTestNG”. Since we are going to create a maven project let's ...
🌐
GitHub
github.com › nguoianphu › selenium-testng-maven
GitHub - nguoianphu/selenium-testng-maven: Seleneium TestNG Maven project · GitHub
Here plugin is used to configure the testing.xml for TestNG test and generate test reports. The maven-compiler-plugin is used to help in compiling the code and using the particular JDK version for compilation. Add all dependencies in the following code snippet, to pom.xml in the node:
Forked by 20 users
Languages   Java
🌐
TestMu AI Community
community.testmuai.com › ask a question
What is Maven and TestNG? - Ask a Question - TestMu AI Community
June 21, 2022 - TetsNG is the Open Source library which helps to organise Selenium Test cases, Execute Test cases in parallel, manage Test data .Maven build tool supports to manage dependencies for selenium project and execution via any CI/CD tool using pom.xml ...
🌐
Quora
quora.com › What-is-the-difference-between-TestNG-and-Maven
What is the difference between TestNG and Maven? - Quora
Answer (1 of 4): TestNG and Maven are two entirely different things. Maven is used for project management. It helps you in building your code/project effectively without much human intervention needed, once you have written your pom.xml correctly. It will download all the required artifacts, res...
🌐
Softpost
softpost.org › testng › testng-integration-with-maven
Maven integration in testng
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name="Component Tests" verbose="2" annotations="JDK"> <test name="a-t1" preserve-order="true" > <classes> <class name="org.softpost.AppTest" /> </classes> </test> </suite> Here is the sample surefire plugin block. <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.19.1</version> <configuration> <suiteXmlFiles> <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> </suiteXmlFiles> <excludedGroups>reg</excludedGroups> <groups>sanity,abc</groups> <parallel>methods</parallel> <threadCount>10</threadCount> <excludes> <exclude>org.softpost.AppTest</exclude> </excludes> </configuration> </plugin> </plugins> </build>
🌐
TOOLSQA
toolsqa.com › testng › testng-dependent-tests
What are TestNG Dependent Tests and How to make test dependent?
September 7, 2021 - Along with that, we may require that a test must run only when another test has run. For example, I want testB to run if testA has run. By this, I denote that testB is dependent on testA, and these are called Dependent Tests in TestNG.
🌐
Selenium
selenium.dev › downloads
Downloads | Selenium
If you're using Maven or Gradle, you will find more information on MVNRepository.
🌐
JetBrains
jetbrains.com › help › idea › testng.html
TestNG | IntelliJ IDEA Documentation
In build.gradle, press Alt+Insert and select Add Maven artifact dependency. In the dialog that opens, type testNG in the search field.