获取“ java.lang.NoClassDefFoundError:com / beust / jcommander / ParameterException”异常
Class cls = Class.forName("TestSuite.TestCases.AddContactHappyPath").getClass();
test.setTestClasses(new Class[] { cls });
test.setTestClasses(new Class[] { AddContactHappyPath.class });
import org.testng.TestNG;
import com.xxx.test.others.AddContactHappyPath;
public class SampCls {
public static void main(String[] args) throws ClassNotFoundException {
TestNG test = new TestNG();
test.setTestClasses(new Class[] { AddContactHappyPath.class });
test.run();
}
}
import org.testng.annotations.*;
public class AddContactHappyPath {
@test()
public void AddContactHappyPathtest() {
System.out.println("hello world");
}
}
[TestNG] Running:
Command line suite
hello world
===============================================
Command line suite
Total tests run: 1, Failures: 0, Skips: 0
===============================================