如何在POM.xml中的testng.xml中执行多个在test方法下定义的类

时间:2017-06-30 06:09:33

标签: maven selenium-webdriver testng

下面是我的testng.xml文件代码:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
    <suite name="SaferSystem" >

        <parameter name="dev_URL" value="http://localhost:8383/" /> 

        <test name="ChromeTest">
            <parameter name="browser" value="Chrome" />
            <parameter name="username" value="jayeshdp@weblineindia.com" />
            <parameter name="password" value="System123" />

            <classes>
                    <class name="com.safer.login.LoginTest" />
                    <class name="com.safer.login.DashboardTest"/>  
            </classes>
        </test> 

以下是我的POM.xml代码:

    <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>SaferSystem</groupId>
      <artifactId>SaferMavenProject</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>jar</packaging>
      <name>SaferMavenProject</name>
      <url>http://maven.apache.org</url>

       <build>
      <sourceDirectory>src/main/java</sourceDirectory>
      <plugins>
       <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
         <source>1.8</source>
         <target>1.8</target>
        </configuration>
       </plugin>
       <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <configuration>
         <suiteXmlFiles>
          <suiteXmlFile>testng.xml</suiteXmlFile>
         </suiteXmlFiles>
        </configuration>
       </plugin>
      </plugins>
     </build>

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

      <dependencies>
         <dependency>
               <groupId>org.seleniumhq.selenium</groupId>
               <artifactId>selenium-java</artifactId>
               <version>2.53.1</version>
         </dependency>
        <dependency>
              <groupId>org.testng</groupId>
              <artifactId>testng</artifactId>
              <version>6.11</version>
         </dependency>
            <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.7</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.7</version>
        </dependency>


      </dependencies>
    </project>

我想执行“DashboardTest”java文件但是当我添加“DashboardTest”时,行代码不会执行。但是,如果我只保留“LoginTest”类,那么代码将正确执行。我怎么能解决这个问题,因为我有多个类要在test下添加。请帮助我,因为我对Maven很新,并且正在开发Maven项目。提前谢谢。

0 个答案:

没有答案