Maven项目给出错误,从命令提示符运行

时间:2018-10-20 06:22:05

标签: maven selenium testing

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

enter image description here

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

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

enter image description here

下面是我的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>

下面是我的Testng文件:

<!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>

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

1 个答案:

答案 0 :(得分:0)

您应按以下方式配置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>