TestNG won't detect my test or build it
I looked through my Maven plugins, structured my folders as it is supposed to be, and annotated the Test as needed. The test won't build at all. Below is the folder structure, code, and also the logs after trying to run the test.
53 Replies
⌛
This post has been reserved for your question.
Hey @Ainhart! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
Can you try just running
mvn test
?
Can you show your pom.xml?PS C:\Users\ainha\Project\main> mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.automation:main >-------------------------
[INFO] Building Selenium Automation Project 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.048 s
[INFO] Finished at: 2025-01-15T02:26:54+09:00
[INFO] ------------------------------------------------------------------------
You have both JUnit and TestNG in your dependencies. Is that intentional?
I think I'll try removing that first
see also https://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html#running-testng-and-junit-tests if you really want both JUnit and TestNG
I only need TestNG, so I removed J Unit
This message has been formatted automatically. You can disable this using
/preferences
.I am getting this instead now
Can you show the full output of
mvn test
again?
or better mvn clean test
PS C:\Users\ainha\Project\main> mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.automation:main >-------------------------
[INFO] Building Selenium Automation Project 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.049 s
[INFO] Finished at: 2025-01-15T02:55:03+09:00
[INFO] ------------------------------------------------------------------------
What's your current pom.xml?
You probably want
<scope>test</scope>
for the test dependencies (TestNG and Selenium)Stack Overflow
Testng test are ignored after upgrading to Sprint Boot 3 and maven-...
I have an application that was executing TestNG tests perfectly with maven, for example, when using a mvn clean install command.
Currently I have updated the application to start using Spring Boot ...
so I updated that to include <scope>test</scope> and the dependency as well
But the scope tag broke my Selenium import
Is that code supposed to be used outside tests?
I have POM java classes that are using Selenium
idk what that means
They are classes representing Pages
but if you want to use Selenium from files in src/main/java, you shouldn't use
<scope>test</scope>
for seleniumAlright, got it
and why are they in src/main/java and not src/test/java?
Is the project supposed to test another project?
No, but that's the recommended structure. The POM objects uses Selenium keywords to identify elements in the web page for easier management
What do you8 mean with POM objects?
I assume you are not talking about project object model?
Page Object Model
BrowserStack
Page Object Model and Page Factory in Selenium | BrowserStack
Understand the fundamental concept of Page Object Model (POM) and Page factory in Selenium along with the example and key differences.
Here's an example
So the project you are working on is supposed testing a website that isn't in this project?
Yeah it's an external webpage
ok yeah then it's fine
So what happens now?
With you adding surefire-testng
It still doesn't work
Does
mvn clean test
still give you the same output?
Can you show your new pom.xml?Yep
you could try updating your versions I guess
specifically of surefire, surefire-testng and testng
oh and I think you shoulod use the same version for the maven-surefire-plugin and surefire-testing
so 3.5.2 in both cases
Still not working
What's the output of
mvn clean compiler:test-compile surefire:test
?[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.159 s
[INFO] Finished at: 2025-01-15T03:24:41+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Could not find goal 'test-compile' in plugin org.apache.maven.plugins:maven-compiler-plugin:3.11.0 among available goals compile, help, testCompile -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoNotFoundException
ok, should be
mvn clean compiler:testCompile surefire:test
But please actually show the full output
and not just the end
This is the full output
oh wait
I noticed something
You used
<pluginManagement>
put the surefire plugin into <build><plugins>
also that error tells you what the issue isNo compiler?
Huh?
You need to run on a JDK
Do you have a JDK installed?
What's the output of
javac --version
?
ohhhhh
you have <packaging>pom</packaging>
remove that
<packaging>pom</packaging>
means you don't have any Java codeOk, let me fix that
javac --version
javac 23.0.1
So I fixed that
This is my current POM
That's my log now
I don't see why the package does not exist
Can you run
mvn test
now
that's probably because it's compiling tests without main sources
that one looks like you still had <packaging>pom</packaging>
though💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
I already removed this one
Sorry, I don't know what this quite means, could you explain? I already compiled the main source but this still occurs
It's ok, I got it figured out, thanks
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@82285533308399616>.