gpt4 book ai didi

java - 在类路径文件中找不到自动测试的问题

转载 作者:行者123 更新时间:2023-11-30 07:37:41 27 4
gpt4 key购买 nike

首先,我只想说我自己为解决这个问题做了很多研究。我在这里查看了一堆答案,并尝试了其中的许多答案,但可惜的是,这无济于事。

我当前的堆栈是带有Maven和Selenium的Eclipse(Mars)。尝试运行自动化测试时,我得到以下信息:


  
    [INFO]扫描项目... [INFO] [INFO]
    -------------------------------------------------- ---------------------- [INFO]楼宇自动化0.0.1-SNAPSHOT [INFO]
    -------------------------------------------------- ---------------------- [警告] org.testng:testng:jar:5.14.3的POM无效,
    传递依赖项(如果有)将不可用,请启用调试
    记录更多详细信息[警告]的POM
    org.testng:testng:jar:5.14.4无效,传递依赖项(如果
    任何)将不可用,请启用调试日志记录以获取更多详细信息
    [警告] org.testng:testng:jar:5.14.5的POM无效,
    传递依赖项(如果有)将不可用,请启用调试
    记录更多详细信息[INFO] [INFO]-
    maven-clean-plugin:2.5:clean(默认清洁)@自动化--- [INFO]
    删除C:\ Users \ bmoore \ workspace \ automation \ target [INFO] [INFO]
    --- maven-resources-plugin:2.6:resources(default-resources)@自动化--- [INFO]使用'UTF-8'编码来复制已过滤的
    资源。 [INFO]复制7个资源[INFO] [INFO]-
    maven-compiler-plugin:3.3:compile(默认编译)@ Automation-
    [INFO]检测到更改-重新编译模块! [INFO]编译253
    源文件到C:\ Users \ bmoore \ workspace \ automation \ target \ classes
    [INFO] [INFO] --- maven-resources-plugin:2.6:testResources
    (default-testResources)@自动化--- [INFO]使用'UTF-8'编码
    复制过滤的资源。 [INFO]复制3个资源[INFO] [INFO]
    --- maven-compiler-plugin:3.3:testCompile(default-testCompile)@自动化--- [信息]检测到更改-重新编译模块!
    [INFO]将17个源文件编译为
    C:\ Users \ bmoore \ workspace \ automation \ target \ test-classes [INFO]
    
    [INFO] --- maven-surefire-plugin:2.19:test(默认测试)@ Automation
  
  
  -------------------------------------------------- -----测试
  -------------------------------------------------- -----运行TestSuite
  
  结果:
  
  测试运行:0,失败:0,错误:0,跳过:0
  
  [信息]
  -------------------------------------------------- ---------------------- [INFO]内置失败[INFO]
  -------------------------------------------------- ---------------------- [INFO]总时间:9.679 s [INFO]完成于:
  2016-02-02T10:26:53-07:00 [INFO]最终内存:23M / 277M [INFO]
  -------------------------------------------------- ---------------------- [ERROR]无法执行目标
  org.apache.maven.plugins:maven-surefire-plugin:2.19:test
  (默认测试)在项目自动化上:执行目标的默认测试
  org.apache.maven.plugins:maven-surefire-plugin:2.19:test失败:存在
  是派生进程[ERROR] org.testng.TestNGException中的错误:
  [错误] [错误]在类路径中找不到类:
  com..qa.automation.roles.SuperAdminCreateCouponTest [错误]
  在org.testng.xml.XmlClass.loadClass(XmlClass.java:81)处[错误]
  org.testng.xml.XmlClass.init(XmlClass.java:73)在[错误]
  org.testng.xml.XmlClass。(XmlClass.java:59)在[错误]
  org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:546)
  在[ERROR]
  com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
  在[ERROR]
  com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
  在[ERROR]
  com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1344)
  在[ERROR]
  com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl $ FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2787)
  在[ERROR]
  com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
  在[ERROR]
  com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
  在[ERROR]
  com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
  在[ERROR]
  com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
  在[ERROR]
  com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
  在[ERROR]
  com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
  在[ERROR]
  com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl $ JAXPSAXParser.parse(SAXParserImpl.java:643)
  在[ERROR]
  com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
  javax.xml.parsers.SAXParser.parse(SAXParser.java:195)上的[错误]
  org.testng.xml.XMLParser.parse(XMLParser.java:38)出现[ERROR]
  在org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:16)[错误]
  在org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:9)[错误]
  在org.testng.xml.Parser.parse(Parser.java:172)处[错误]在
  org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:300)[错误]
  在org.testng.TestNG.run(TestNG.java:1021)处[错误]
  org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:282)
  在[ERROR]
  org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:83)
  在[ERROR]
  org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:114)
  在[ERROR]
  org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:286)
  在[ERROR]
  org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:240)
  在[ERROR]
  org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)
  [错误]-> [帮助1] [错误] [错误]要查看的完整堆栈跟踪
  错误,使用-e开关重新运行Maven。 [错误]重新运行Maven
  使用-X开关启用完整的调试日志记录。 [错误] [错误]为
  有关错误的更多信息和可能的解决方案,请阅读
  以下文章:[错误] [帮助1]
  http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException


那就是发生的一切的全部痕迹。问题(如我所见)与以下几行有关:


  [错误]无法在项目自动化上执行目标org.apache.maven.plugins:maven-surefire-plugin:2.19:test(默认测试):执行目标org.apache.maven.plugins:maven-surefire的默认测试-plugin:2.19:test失败:分叉过程中出现错误
  [错误] org.testng.TestNGException:
  [错误]
  [错误]在类路径中找不到类:com..qa.automation.roles.SuperAdminCreateCouponTest


我已经尝试验证类路径条目,并且存在surefire插件。在两种情况下,它们都是应有的位置。我已经尝试一次提交文件,并且行得通。仅当我构建时,我才遇到问题,这使我无法完全运行自动化。

我猜想这个问题很可能很容易解决,但是Java / Eclipse堆栈对我来说并不是第二位,就像.NET / C#一样。

注意:如果有问题,我将用新信息更新问题。

更新:我包括以下POM:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.kryterion.qa</groupId>
<artifactId>automation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>automation</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skipTests>false</skipTests>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.9</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.48.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.48.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.48.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.48.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.37</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10-FINAL</version>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.11.1.1</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.2.8</version>
</dependency>
</dependencies>
<build>
<finalName>automation</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<skipTests>${skipTests}</skipTests>
<systemPropertyVariables>
<environment>${envName}</environment>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.16</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changelog-plugin</artifactId>
<version>2.2</version>
<configuration>
<issueLinkUrl>http://prodjira01:8080/browse/%ISSUE%</issueLinkUrl>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<show>private</show>
<additionalparam>${javadoc.doclint.none}</additionalparam>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.4</version>
<configuration>
<linkXRef>true</linkXRef>
<source>1.8</source>
<targetJdk>1.8</targetJdk>
<rulesets>
<ruleset>/rulesets/java/basic.xml</ruleset>
<ruleset>/rulesets/java/braces.xml</ruleset>
<ruleset>/rulesets/java/design.xml</ruleset>
</rulesets>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>taglist-maven-plugin</artifactId>
<version>2.4</version>
<configuration>
<tagListOptions>
<tagClasses>
<tagClass>
<displayName>Todo</displayName>
<tags>
<tag>
<matchString>todo</matchString>
<matchType>ignoreCase</matchType>
</tag>
<tag>
<matchString>FIXME</matchString>
<matchType>ignoreCase</matchType>
</tag>
<tag>
<matchString>NB</matchString>
<matchType>exact</matchType>
</tag>
</tags>
</tagClass>
<tagClass>
<displayName>Deprecated</displayName>
<tags>
<tag>
<matchString>@deprecated</matchString>
<matchType>ignoreCase</matchType>
</tag>
</tags>
</tagClass>
</tagClasses>
</tagListOptions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<xmlOutput>true</xmlOutput>
<!-- Optional directory to put findbugs xdoc xml report -->
<xmlOutputDirectory>target/site</xmlOutputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>config/sun_checks.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>
</project>


@sircapsalot-我做了以下建议的更改,发生的是所有这些更改:

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;


突然开始在所有具有这些输入的类中发出警告。有什么想法吗?

最佳答案

根据Maven Central,您所请求的版本不存在。 (您正在请求org.testng:testng:jar:5.14.3)

尝试更新到最新版本:pom.xml中的6.9.10

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
</dependency>


maven central search

关于java - 在类路径文件中找不到自动测试的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35160262/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com