简体   繁体   中英

How to use a test class from a jar in TestNG

I have a JAR(xyz.jar) with test class test.sample.ClassX . I am trying to use this class in testng.xml shown below,

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="SuiteX" verbose="1" >
  <test name="TestX"   >
     <classes>
        <class name="test.sample.ClassX" />
    </classes>
 </test>
</suite>

My pom.xml has dependency(xyz.jar) added. I can execute this suite from eclipse but fails when i try to execute from command-line(mac) with below error,

error: package test.sample does not exist

Any idea what the issue might be ?

My first guess is that you might not have a class defined like:

package test.sample;

public class TestX
{
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM