TERACytE
TERACytE

Reputation: 7863

How to load TestNG config within an executable JAR?

I have an shaded executable jar created by a Maven build. Within I have a main class that executes and attempts to run a collection of TestNG tests. It runs until it it attempts to load the xml config files for the tests. The steps within the main class are:

    suites.add("testng-A.xml");
    suites.add("testng-B.xml");

    testng.setTestSuites(suites);
    testng.addListener(tla);
    testng.run();

The problem is that I cannot get TestNG to successfully find the xml files. I receive a "java.io.FileNotFoundException: testng-a.xml (No such file or directory)" error. The location of the files in the JAR are:

    /com/address/MyMainClass 
    /testng-a.xml
    /testng-b.xml

I am running the jar with the following command:

    java -jar uber.jar

Any ideas on how I can get this to work?

Upvotes: 1

Views: 3084

Answers (1)

TERACytE
TERACytE

Reputation: 7863

It looks like this cannot be done within the JAR. The testng xml configs cannot be loaded in this manner. The files need to be external from the JAR before loading.

http://groups.google.com/group/testng-users/browse_thread/thread/ad7e33342125e717?hl=en&pli=1

Upvotes: 2

Related Questions