【问题标题】:Maven project giving error, running from command promptMaven项目给出错误,从命令提示符运行
【发布时间】:2018-10-20 06:22:05
【问题描述】:

我能够成功编译我的 maven 项目。

我还能够从 Eclipse Run As--> TestNG Suite 成功运行我的项目

但是从命令提示符 ad mvn test 运行项目。它给出以下错误:

下面是我的 POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.ShellTesting</groupId>
  <artifactId>Shell_AutomationTesting</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>Shell_AutomationTesting</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

<dependencies>
  <!--  POI  -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml-schemas</artifactId>
        <version>3.6</version>
    </dependency>
    <dependency>
        <groupId>dom4j</groupId>
        <artifactId>dom4j</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.xmlbeans</groupId>
        <artifactId>xmlbeans</artifactId>
        <version>2.3.0</version>
    </dependency>

<!--Selenium-->

        <dependency>
                 <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-java</artifactId>
                 <version>2.53.0</version>
         </dependency>
        <dependency>
            <groupId>com.relevantcodes</groupId>
            <artifactId>extentreports</artifactId>
            <version>2.40.1</version>
        </dependency>

<!--Testng -->

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.9.6</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire</artifactId>
            <version>2.18.1</version>
            <type>pom</type>
        </dependency>

<!--  Appium -->

        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>3.3.0</version>
        </dependency>


        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.3</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>17.0</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>commons-validator</groupId>
            <artifactId>commons-validator</artifactId>
            <version>1.4.1</version>
        </dependency>

<!-- Java mail api -->

    <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4</version>
    </dependency>



</dependencies>


  <build>
  <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.1</version>
        <configuration>
          <suiteXmlFiles>
            <suiteXmlFile>testng.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
          </plugin>


  </plugins>
    </build>
</project>

下面是我的测试文件:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="My Sample Suite" allow-return-values="true">

<test name="TC01_01_HomePage" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC01_01_HomePage" />  
    </classes>
</test>

<test name="TC02_01_59831_Transactions" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC02_01_59831_Transactions" />  
    </classes>
</test>

<test name="TC03_01_36956_CardActivity" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC03_01_36956_CardActivity" />  
    </classes>
</test>

<test name="TC04_01_36940_CardList" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC04_01_36940_CardList" />  
    </classes>
</test>

<test name="TC05_01_58462_CardDetails" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC05_01_58462_CardDetails" />  
    </classes>
</test>

<test name="TC06_01_53631_OrderACard" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC06_01_53631_OrderACard" />  
    </classes>
</test>

<test name="TC06_02_51978_OrderACard" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC06_02_51978_OrderACard" />  
    </classes>
</test>

<test name="TC06_03_58019_RestrictionProfileWhileOrderingCards" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC06_03_58019_RestrictionProfileWhileOrderingCards" />  
    </classes>
</test>

<test name="TC07_01_50270_Restrictions" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC07_01_50270_Restrictions" />  
    </classes>
</test>

<test name="TC08_01_37024_CardBlockUnblock" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC08_01_37024_CardBlockUnblock" />  
    </classes>
</test>

<test name="TC09_01_72039_AccountSwitcher" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC09_01_72039_AccountSwitcher" />  
    </classes>
</test>

<test name="TC10_01_58451_Interstitial" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC10_01_58451_Interstitial" />  
    </classes>
</test>

<test name="TC11_01_Invoices" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC11_01_Invoices" />  
    </classes>
</test>

<test name="TC12_01_57230_UserManagement" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC12_01_57230_UserManagement" />  
    </classes>
</test>

<test name="TC13_01_85008_CustomConfiguration" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC13_01_85008_CustomConfiguration" />  
    </classes>
</test>

<test name="TC14_01_58948_SiteSettings" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC14_01_58948_SiteSettings" />  
    </classes>
</test>

<test name="TC15_01_63848_MarketConfiguration" allow-return-values="true">
    <classes>
        <class name="com.ShellAutomation.Testcases.TC15_01_63848_MarketConfiguration" />  
    </classes>
</test>

</suite>

我试图寻找解决方案,但我无法弄清楚,为什么它会抛出错误

【问题讨论】:

  • 点评来源: 请将您的错误作为文本添加到您的问题中。请参阅:How to AskHow to write a Minimal, Complete, and Verifiable example
  • 最好在帖子中放文字而不是图片...
  • 其他用户将您的问题标记为低质量和需要改进。我重新措辞/格式化您的输入,使其更容易阅读/理解。请查看我的更改以确保它们反映您的意图。但我认为你的问题仍然无法回答。 现在应该edit你的问题,添加缺失的细节(见minimal reproducible example)。如果您对我有其他问题或反馈,请随时给我留言。
  • 特别是:阅读no pictures of exceptions / no pictures of code。然后使用edit 链接在您的问题中用格式正确/缩进的文本替换文本的屏幕截图。

标签: maven selenium testing


【解决方案1】:

你应该像下面这样配置 maven-compiler-plugin:

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
    [...]
  </build>
  [...]
</project>

【讨论】:

  • Thnx...已相应配置....但现在在'mvn test'上给出成功结果而不执行测试
  • 问题是如何命名测试?他们在哪里?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-08-10
  • 1970-01-01
  • 2014-12-13
  • 2011-06-30
  • 1970-01-01
  • 1970-01-01
  • 2014-07-09
相关资源
最近更新 更多