java - How to run TestNG tests from main() in an executable jar? -


i have executable jar contains dependencies , test classes. i've confirmed main() method called when execute jar. i'm trying add code main() can run specific testng test class. documentation on testng.org appears way it:

    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 typical:

    /src/main/java/main.java     /src/test/java/com/some/path/tests/mytests.java 

however when try compile error:

    java: /src/main/java/main.java:46: package com.some.path.tests not exist 

is there anyway can alter project testng.settestclasses() in main() can access test class?

i used following in main() method , worked.

    commandlineoptions options = new commandlineoptions();     jcommander jcommander = new jcommander(options, args);      xmlsuite suite = new xmlsuite();     suite.setname("mytestsuite");     suite.setparameters(options.converttomap());      list<xmlclass> classes = new arraylist<xmlclass>();     classes.add(new xmlclass("com.some.path.tests.mytests"));      xmltest test = new xmltest(suite);     test.setname("mytests");     test.setxmlclasses(classes);      list<xmlsuite> suites = new arraylist<xmlsuite>();     suites.add(suite);      testng testng = new testng();     testng.setxmlsuites(suites);     testng.run(); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -