I have an executable JAR that contains all the dependencies and test classes. I confirmed that the main () method is called when the jar is executed. I am trying to add code to main () so that I can run a specific TestNG test class. From the documentation on TestNG.org, this seems to be the way to do this:
TestListenerAdapter tla = new TestListenerAdapter(); TestNG testng = new TestNG(); testng.setTestClasses(new Class[] { com.some.path.tests.MyTests.class }); testng.addListener(tla); testng.run();
My folder structure is typical:
/src/main/java/Main.java /src/test/java/com/some/path/tests/MyTests.java
However, when I try to compile it, I get this error:
java: /src/main/java/Main.java:46: package com.some.path.tests does not exist
Anyway, can I change my project so that testng.setTestClasses () in main () can access the test class?
java jar unit-testing executable-jar testng
TERACytE
source share