简体   繁体   English

[TestNG][Jar] Set Classpath in Manifest (Class-Path) — 忽略类路径?

[英][TestNG][Jar] Set Classpath in Manifest (Class-Path) — classpath is ignored?

I'm trying to run a simple TestNG test case residing within a jar file, which contains the test and manifest:我正在尝试运行驻留在 jar 文件中的简单 TestNG 测试用例,其中包含测试和清单:

ex.) Test.jar contains: { META-INF\ META-INF\MANIFEST.MF tests\ tests\Test01.class }例如)Test.jar 包含:{ META-INF\ META-INF\MANIFEST.MF 测试\测试\Test01.class }

I am trying to run it using the command: java org.testng.TestNG - testjar Test.jar testng.xml I am trying to run it using the command: java org.testng.TestNG - testjar Test.jar testng.xml

Where a folder contains (all in the same directory): Test.jar testng.xml testng-6.1.1.jar文件夹包含的位置(全部在同一目录中):Test.jar testng.Z0F635D0E0F3874FFF8B581C1374FFF8B581C1374FFF8B581C1322E6C7A7Z testng-6.1.1.1.Z689945ZDBF443

And Manifest contains (w/ a line-break at the end): Manifest-Version: 1.0 Created-By: Willie Owens Class-Path: testng-6.1.1.jar Test.jar.清单包含(末尾有换行符):清单版本:1.0 创建者:Willie Owens 类路径:testng-6.1.1.jar Test.jar。

And I get a NoClassDefFoundError: org/testng/TestNG.我得到一个 NoClassDefFoundError: org/testng/TestNG。 Could not find main class.找不到主 class。

If I specify the classpath using -cp after "java" (Ex. java -cp testng-6.1.1.jar;Test.jar org.testng.TestNG -testjar Test.jar testng.xml) it works, but I want this information in the manifest. If I specify the classpath using -cp after "java" (Ex. java -cp testng-6.1.1.jar;Test.jar org.testng.TestNG -testjar Test.jar testng.xml) it works, but I want this清单中的信息。 What am I doing wrong here?我在这里做错了什么?

Also, I've tried every variation I could think of when typing in the Class-Path, such as: ./testng-6.1.1.jar.\testng-6.1.1.jar...etc..此外,我已经尝试了在 Class-Path 中键入时我能想到的所有变体,例如:./testng-6.1.1.jar.\testng-6.1.1.jar...等。

HELP帮助

Executing test-jar is not that complex with testNg please refer [1] for more detail.使用 testNg 执行 test-jar 并不复杂,请参阅 [1] 了解更多详细信息。

lease let me know if you find any pitfalls with it.如果您发现任何陷阱,请告诉我。

[1] http://dharshanaw.blogspot.com/2012/10/how-to-execute-testng-tests-in-side.html [1] http://dharshanaw.blogspot.com/2012/10/how-to-execute-testng-tests-in-side.html

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

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