简体   繁体   English

如何从TestNG的jar中使用测试类

[英]How to use a test class from a jar in TestNG

I have a JAR(xyz.jar) with test class test.sample.ClassX . 我有一个带有测试类test.sample.ClassX的JAR(xyz.jar)。 I am trying to use this class in testng.xml shown below, 我正在尝试在testng.xml显示的testng.xml中使用此类,

<!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. 我的pom.xml添加了依赖项(xyz.jar)。 I can execute this suite from eclipse but fails when i try to execute from command-line(mac) with below error, 我可以从Eclipse执行此套件,但是当我尝试从命令行(mac)执行以下错误时失败,

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
{
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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