testng.xml的批处理文件未按计划运行

时间:2018-09-05 21:56:02

标签: java shell testng

According to this question,我已经创建了一个批处理文件并为其创建了计划任务。但是,它不会在计划的时间运行。 我尝试执行注释testng.xml行的脚本,并在bin和lib的路径中看到一个空格。

这可能是原因吗?请有任何想法。

这是我的剧本:

set ProjectPath=C:\Users\workspace\RestAssured 
echo %ProjectPath%
set classpath=%ProjectPath%\bin;%ProjectPath%\Lib\*
echo %classpath%
java org.testng.TestNG %ProjectPath%\testng.xml

系统抛出以下classNotFoundException:

  

错误:找不到或加载主类org.testng.TestNG

     

原因:java.lang.ClassNotFoundException:org.testng.TestNG

这是错误日志:

  

C:\ Users \ eclipse-workspace \ RestAssured> set classpath = C:\ Users \ eclipse-workspace \ RestAssured \ bin; C:\ Users \ eclipse-workspace \ RestAssured \ lib *

     

C:\ Users \ eclipse-workspace \ RestAssured> echo C:\ Users \ eclipse-workspace \ RestAssured \ bin; C:\ Users \ eclipse-workspace \ RestAssured \ lib *

     

C:\ Users \ eclipse-workspace \ RestAssured \ bin; C:\ Users \ eclipse-workspace \ RestAssured \ lib *

     

C:\ Users \ eclipse-workspace \ RestAssured> java org.testng.TestNG>

     

C:\ Users \ eclipse-workspace \ RestAssured \ testng.xml

     

错误:找不到或加载主类org.testng.TestNG

     

原因:java.lang.ClassNotFoundException:org.testng.TestNG

     

构建步骤“执行Windows批处理命令”将构建标记为失败

这是TestNG的详细信息:

> ...
... TestNG 6.9.6 by C??dric Beust (cedric@beust.com)
...

[TestRunner] Running the tests in 'Rep' with parallel mode:tests
[RunInfo] Adding method selector: org.testng.internal.XmlMethodSelector@3857f613 priority: 10
[TestClass] Creating TestClass for [ClassImpl class=com.root.com.RepZmap]
[TestClass] Adding method RepZmap.ZmapTest()[pri:0, instance:null] on TestClass class com.root.com.RepZmap
[XmlMethodSelector] Including method com.root.com.sendEmailReport()
[XmlMethodSelector] Including method com.root.com.startTest()
[XmlMethodSelector] Including method com.root.com.endReport()
[XmlMethodSelector] Including method com.root.com.initializeValues()
[XmlMethodSelector] Including method com.root.com.reportHeader()
[XmlMethodSelector] Including method com.root.com.getResult()
[TestClass] Creating TestClass for [ClassImpl class=com.root.com.RepMir112]
[TestClass] Adding method RepMir112.MirTest()[pri:0, instance:null] on TestClass class com.root.com.RepMir112
[TestClass] Creating TestClass for [ClassImpl class=com.root.com.RepMir113]
[TestClass] Adding method RepMir113.Mir113Test(java.lang.String, java.lang.String, java.lang.String)[pri:0, instance:null] on TestClass class com.root.com.RepMir113
[XmlMethodSelector] Including method com.root.com.ZmapTest()
[XmlMethodSelector] Including method com.root.com.MirTest()
[XmlMethodSelector] Including method com.root.com.Mir113Test()
[TestNG] Running:
  C:\Users\mhuntik\eclipse-workspace\RestAssured\testng.xml

[SuiteRunner] Created 1 TestRunners
[ThreadUtil] Starting executor timeOut:2147483647ms workers:1 threadPoolSize:5
[[SuiteWorker]] Running XML Test 'Rep' in Parallel
[TestRunner] Running test Rep on 3  classes,  included groups:[] excluded groups:[]
===== Test class
com.root.com.RepZmap
  @BeforeClass RepZmap.initializeValues()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5]
  @BeforeMethod RepUtils.reportHeader(java.lang.reflect.Method)[pri:0, instance:com.root.com.RepZmap@5fd4f8f5]
    @Test RepZmap.ZmapTest()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5]
  @AfterMethod RepUtils.getResult(org.testng.ITestResult)[pri:0, instance:com.root.com.RepZmap@5fd4f8f5]
======
===== Test class
com.root.com.RepMir112
  @BeforeClass RepMir112.initializeValues()[pri:0, instance:com.root.com.RepMir112@6631f5ca]
  @BeforeMethod RepUtils.reportHeader(java.lang.reflect.Method)[pri:0, instance:com.root.com.RepMir112@6631f5ca]
    @Test RepMir112.MirTest()[pri:0, instance:com.root.com.RepMir112@6631f5ca]
  @AfterMethod RepUtils.getResult(org.testng.ITestResult)[pri:0, instance:com.root.com.RepMir112@6631f5ca]
======
===== Test class
com.root.com.RepMir113
  @BeforeClass RepMir113.initializeValues()[pri:0, instance:com.root.com.RepMir113@5ace1ed4]
  @BeforeMethod RepUtils.reportHeader(java.lang.reflect.Method)[pri:0, instance:com.root.com.RepMir113@5ace1ed4]
    @Test RepMir113.Mir113Test(java.lang.String, java.lang.String, java.lang.String)[pri:0, instance:com.root.com.RepMir113@5ace1ed4]
  @AfterMethod RepUtils.getResult(org.testng.ITestResult)[pri:0, instance:com.root.com.RepMir113@5ace1ed4]
======
[Invoker 1303063064] Keeping method RepUtils.startTest()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5] for class null
[Invoker 1303063064] Invoking @BeforeTest RepUtils.startTest()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5]
[Invoker 1303063064] Keeping method RepZmap.initializeValues()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5] for class [TestClass name=class com.root.com.RepZmap]
[Invoker 1303063064] Invoking @BeforeClass RepZmap.initializeValues()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5]
[Invoker 1303063064] Keeping method RepUtils.reportHeader(java.lang.reflect.Method)[pri:0, instance:com.root.com.RepZmap@5fd4f8f5] for class [TestClass name=class com.root.com.RepZmap]
[Invoker 1303063064] Keeping method RepUtils.getResult(org.testng.ITestResult)[pri:0, instance:com.root.com.RepZmap@5fd4f8f5] for class [TestClass name=class com.root.com.RepZmap]
[Invoker 1303063064] Keeping method RepUtils.reportHeader(java.lang.reflect.Method)[pri:0, instance:com.root.com.RepZmap@5fd4f8f5] for class [TestClass name=class com.root.com.RepZmap]
[Invoker 1303063064] Invoking @BeforeMethod RepUtils.reportHeader(java.lang.reflect.Method)[pri:0, instance:com.root.com.RepZmap@5fd4f8f5]
[Invoker 1303063064] Invoking com.root.com.RepZmap.ZmapTest
--------- Sending IPs To Receiver --------------------
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.poi.openxml4j.util.ZipSecureFile$1 (file:/C:/Users/mhuntik/eclipse-workspace/RestAssured/lib/fillo-1.18.jar) to field java.io.FilterInputStream.in
WARNING: Please consider reporting this to the maintainers of org.apache.poi.openxml4j.util.ZipSecureFile$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[Invoker 1303063064] Keeping method RepUtils.getResult(org.testng.ITestResult)[pri:0, instance:com.root.com.RepZmap@5fd4f8f5] for class [TestClass name=class com.root.com.RepZmap]
[Invoker 1303063064] Invoking @AfterMethod RepUtils.getResult(org.testng.ITestResult)[pri:0, instance:com.root.com.RepZmap@5fd4f8f5]
log4j:WARN No appenders could be found for logger (freemarker.cache).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[Invoker 1303063064] Keeping method RepMir112.initializeValues()[pri:0, instance:com.root.com.RepMir112@6631f5ca] for class [TestClass name=class com.root.com.RepMir112]
[Invoker 1303063064] Invoking @BeforeClass RepMir112.initializeValues()[pri:0, instance:com.root.com.RepMir112@6631f5ca]
[Invoker 1303063064] Keeping method RepUtils.reportHeader(java.lang.reflect.Method)[pri:0, instance:com.root.com.RepMir112@6631f5ca] for class [TestClass name=class com.root.com.RepMir112]
[Invoker 1303063064] Keeping method RepUtils.getResult(org.testng.ITestResult)[pri:0, instance:com.root.com.RepMir112@6631f5ca] for class [TestClass name=class com.root.com.RepMir112]
[Invoker 1303063064] Keeping method RepUtils.reportHeader(java.lang.reflect.Method)[pri:0, instance:com.root.com.RepMir112@6631f5ca] for class [TestClass name=class com.root.com.RepMir112]
[Invoker 1303063064] Invoking @BeforeMethod RepUtils.reportHeader(java.lang.reflect.Method)[pri:0, instance:com.root.com.RepMir112@6631f5ca]
[Invoker 1303063064] Invoking com.root.com.RepMir112.MirTest
--------- Sending IPs To Receiver --------------------
[Invoker 1303063064] Keeping method RepUtils.getResult(org.testng.ITestResult)[pri:0, instance:com.root.com.RepMir112@6631f5ca] for class [TestClass name=class com.root.com.RepMir112]
[Invoker 1303063064] Invoking @AfterMethod RepUtils.getResult(org.testng.ITestResult)[pri:0, instance:com.root.com.RepMir112@6631f5ca]
[Invoker 1303063064] Keeping method RepMir113.initializeValues()[pri:0, instance:com.root.com.RepMir113@5ace1ed4] for class [TestClass name=class com.root.com.RepMir113]
[Invoker 1303063064] Invoking @BeforeClass RepMir113.initializeValues()[pri:0, instance:com.root.com.RepMir113@5ace1ed4]
[Invoker 1303063064] Keeping method RepUtils.reportHeader(java.lang.reflect.Method)[pri:0, instance:com.root.com.RepMir113@5ace1ed4] for class [TestClass name=class com.root.com.RepMir113]
[Invoker 1303063064] Keeping method RepUtils.getResult(org.testng.ITestResult)[pri:0, instance:com.root.com.RepMir113@5ace1ed4] for class [TestClass name=class com.root.com.RepMir113]
[Invoker 1303063064] Keeping method RepUtils.endReport()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5] for class null
[Invoker 1303063064] Invoking @AfterTest RepUtils.endReport()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5]
===== Invoked methods
  RepUtils.startTest()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5] 1607792885
  RepZmap.initializeValues()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5] 1607792885
  RepUtils.reportHeader(java.lang.reflect.Method)[pri:0, instance:com.root.com.RepZmap@5fd4f8f5]public void com.root.com.RepZmap.ZmapTest() throws java.lang.Throwable  1607792885
    RepZmap.ZmapTest()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5] 1607792885
  RepUtils.getResult(org.testng.ITestResult)[pri:0, instance:com.root.com.RepZmap@5fd4f8f5][TestResult name=ZmapTest status=FAILURE method=RepZmap.ZmapTest()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5] output={null}]  1607792885
  RepMir112.initializeValues()[pri:0, instance:com.root.com.RepMir112@6631f5ca] 1714550218
  RepUtils.reportHeader(java.lang.reflect.Method)[pri:0, instance:com.root.com.RepMir112@6631f5ca]public void com.root.com.RepMir112.MirTest() throws java.lang.Throwable  1714550218
    RepMir112.MirTest()[pri:0, instance:com.root.com.RepMir112@6631f5ca] 1714550218
  RepUtils.getResult(org.testng.ITestResult)[pri:0, instance:com.root.com.RepMir112@6631f5ca][TestResult name=MirTest status=FAILURE method=RepMir112.MirTest()[pri:0, instance:com.root.com.RepMir112@6631f5ca] output={null}]  1714550218
  RepMir113.initializeValues()[pri:0, instance:com.root.com.RepMir113@5ace1ed4] 1523457748
  RepUtils.endReport()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5] 1607792885
=====
Creating C:\Users\mhuntik\eclipse-workspace\RestAssured\test-output\Repute\Rep.html
Creating C:\Users\mhuntik\eclipse-workspace\RestAssured\test-output\Repute\Rep.xml
FAILED: ZmapTest
java.lang.NoSuchFieldError: DEF_CONTENT_CHARSET
        at io.restassured.config.EncoderConfig.<init>(EncoderConfig.java:61)
        at io.restassured.config.RestAssuredConfig.<init>(RestAssuredConfig.java:41)
        at io.restassured.RestAssured.<clinit>(RestAssured.java:420)
        at com.root.com.RepZmap.ZmapTest(RepZmap.java:44)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:821)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
        at org.testng.TestRunner.privateRun(TestRunner.java:773)
        at org.testng.TestRunner.run(TestRunner.java:623)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
        at org.testng.SuiteRunner.access$000(SuiteRunner.java:39)
        at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:391)
        at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
        at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)

FAILED: MirTest
java.lang.NoClassDefFoundError: Could not initialize class io.restassured.RestAssured
        at com.root.com.RepMir112.MirTest(RepMir112.java:44)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:821)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
        at org.testng.TestRunner.privateRun(TestRunner.java:773)
        at org.testng.TestRunner.run(TestRunner.java:623)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
        at org.testng.SuiteRunner.access$000(SuiteRunner.java:39)
        at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:391)
        at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
        at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)

SKIPPED: Mir113Test
java.lang.RuntimeException: java.lang.NoClassDefFoundError: jxl/Workbook
        at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:162)
        at org.testng.internal.Parameters.handleParameters(Parameters.java:430)
        at org.testng.internal.Invoker.handleParameters(Invoker.java:1276)
        at org.testng.internal.Invoker.createParameters(Invoker.java:992)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1082)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
        at org.testng.TestRunner.privateRun(TestRunner.java:773)
        at org.testng.TestRunner.run(TestRunner.java:623)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
        at org.testng.SuiteRunner.access$000(SuiteRunner.java:39)
        at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:391)
        at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
        at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: jxl/Workbook
        at com.root.com.RepMir113.getExcelData(RepMir113.java:36)
        at com.root.com.RepMir113.createSourceIPs(RepMir113.java:57)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
        at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:136)
        ... 16 more
Caused by: java.lang.ClassNotFoundException: jxl.Workbook
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        ... 24 more


===============================================
    Rep
    Tests run: 3, Failures: 2, Skips: 1
===============================================

[Invoker 2014461570] Keeping method RepUtils.sendEmailReport()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5] for class null
[Invoker 2014461570] Invoking @AfterSuite RepUtils.sendEmailReport()[pri:0, instance:com.root.com.RepZmap@5fd4f8f5]
Mail sent successfully...

===============================================
Repute
Total tests run: 3, Failures: 2, Skips: 1
===============================================

1 个答案:

答案 0 :(得分:2)

您真的有一个名为“ Lib”的目录吗?我希望“ lib”在那里,因为Windows是区分大小写的操作系统。