为什么我在远程计算机上运行 jar 文件时出现此错误,所有权限都可以访问该文件

问题描述 投票:0回答:1
C:\\Users\\0641351\\Desktop\>java -jar CreatePSWithPrivateDuty1.jar
java.io.IOException: The device is not ready
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.WinNTFileSystem.canonicalize(Unknown Source)
at java.io.File.getCanonicalPath(Unknown Source)
at org.testng.xml.Parser.parse(Parser.java:151)
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:310)
at org.testng.TestNG.run(TestNG.java:1006)
at TestNgRunner.Poc_Xml_Runner.main(Poc_Xml_Runner.java:15)
\[TestNG\] \[ERROR\] No test suite found. Nothing to run
Usage: \<main class\> \[options\] The XML suite files to run
Options:

>!     -configfailurepolicy

Configuration failure policy (skip or continue)

>!     -d

Output directory

>!     -dataproviderthreadcount

Number of threads to use when running data providers

>!     -excludegroups

Comma-separated list of group names to  exclude

>!     -groups

Comma-separated list of group names to be run

>!     -junit

JUnit mode
Default: false

>!     -listener

List of .class files or list of class names implementing ITestListener or
ISuiteListener

>!     -methods

Comma separated of test methods
Default: \[\]

>!     -methodselectors

List of .class files or list of class names implementing IMethodSelector

>!     -mixed

Mixed mode - autodetect the type of current test and run it with
appropriate runner
Default: false

>!     -objectfactory

List of .class files or list of class names implementing
ITestRunnerFactory

>!     -parallel

Parallel mode (methods, tests or classes)

>!     -port

The port

>!     -reporter

Extended configuration for custom report listener

>!     -suitename

Default name of test suite, if not specified in suite definition file or
source code

>!     -suitethreadpoolsize

Size of the thread pool to use to run suites
Default: 1

>!     -testclass

The list of test classes

>!     -testjar

A jar file containing the tests

>!     -testname

Default name of test, if not specified in suitedefinition file or source
code

>!     -testnames

The list of test names to run

>!     -testrunfactory, -testRunFactory

The factory used to create tests

>!     -threadcount

Number of threads to use when running tests in parallel

>!     -usedefaultlisteners

Whether to use the default listeners
Default: true

>!     -log, -verbose

Level of verbosity

>!     -xmlpathinjar

The full path to the xml file inside the jar file (only valid if -testjar
was specified)[tag:tag-name]
Default: testng.xml

我尝试了 chkdsk 命令

尝试使用相对和绝对路径来运行 jar 内的 xml 文件

想要运行jar文件

java selenium-webdriver testing automation testng
1个回答
0
投票

您需要确保已构建一个包含测试类的 jar。您的帖子没有解释是否是这种情况。

请参阅 https://testng.org/#_running_tests_from_within_a_test_jar 查看如何使用 TestNG 运行属于 jar 的测试的完整示例。

要指示 TestNG 在 jar 中查找测试,您应该使用

-testjar
命令行参数,如果您希望 TestNG 使用 jar 中的特定套件文件,您需要通过命令行参数提供位置
-xmlpathinjar

以下是示例命令:

java -jar target/uber-testjar-demo-1.0-SNAPSHOT-test-jar-with-dependencies.jar \
-testjar target/uber-testjar-demo-1.0-SNAPSHOT-tests.jar \
-xmlpathinjar suites/suite2.xml
© www.soinside.com 2019 - 2024. All rights reserved.