zoukankan      html  css  js  c++  java
  • [个人笔记]IDEA+MAVEN+testNG(reportNG)

    参考:

    http://blog.csdn.net/langsand/article/details/53764805

    http://blog.csdn.net/langsand/article/details/53764805

    1.maven 的pom.xml配置:

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

    <dependencies>

    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.53.0</version>
    <scope>compile</scope>
    </dependency>
        <dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.11</version>
    <scope>test</scope>
    </dependency>


    <!-- https://mvnrepository.com/artifact/com.google.inject/guice -->
    <dependency>
    <groupId>com.google.inject</groupId>
    <artifactId>guice</artifactId>
    <version>4.1.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/velocity/velocity-dep -->
    <dependency>
    <groupId>velocity</groupId>
    <artifactId>velocity-dep</artifactId>
    <version>1.4</version>
    </dependency>
    <dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
    </dependency>
    <dependency>
    <groupId>org.uncommons</groupId>
    <artifactId>reportng</artifactId>
    <version>1.1.4</version>
    <scope>test</scope>
    <exclusions>
    <exclusion>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    </exclusion>
    </exclusions>
    </dependency>
    </dependencies>

    <build>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
    <source>1.7</source>
    <target>1.7</target>
    <compilerArgs>
    <arg>-Xlint:unchecked</arg>
    <arg>-Xlint:deprecation </arg>
    <!--<arg>endorseddirs=${endorsed.dir}</arg>-->
    </compilerArgs>
    </configuration>
    </plugin>
    <!--添加插件 关联testNg.xml-->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.5</version>
    <configuration>
    <testFailureIgnore>true</testFailureIgnore>
    <!--这里设置关联的testNG.xml路径,项目根目录下的res文件夹里面-->
    <suiteXmlFiles>
    <file>res/testNG.xml</file>
    </suiteXmlFiles>

    <properties>

    <!--刚开始这里没有设置默认监听false,所以没有启用reportNG功能。-->
                        <property>
    <name>usedefaultlisteners</name>
    <value>false</value>
    </property>

    <!--Setting ReportNG listener-->
    <property>
    <name>listener</name>
    <value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
    </property>

    </properties>
    <workingDirectory>target/</workingDirectory>
    <forkMode>always</forkMode>
    </configuration>
    </plugin>
    </plugins>
    </build>
    2.testNG.xml配置listener

    <?xml version="1.0" encoding="utf-8" ?>
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
    <suite name="testproj" parallel="false">
    <test name="testDemo1">
    <packages>
    <package name="com.aika.testng"/>
    </packages>
    <!--<classes>-->
    <!--<class name="com.aika.testng.*"></class>-->
    <!--</classes>-->
    </test>

    <!--<listeners>-->
    <!--<listener class-name="org.uncommons.reportng.HTMLReporter" />-->
    <!--<listener class-name="org.uncommons.reportng.JUnitXMLReporter" />-->
    <!--</listeners>-->


    </suite>
    上面testNG.xml不设置的话,可以这样设置




    3.配置好了,写一个简单的测试用例,此处不多做说明了。
    IDEA的终端Terminal窗口,输入:mvn -f pom.xml clean test -DxmlFileName=testNG.xml
    testNG.xml对应配置文件名称

    生成成功,红框路径打开index.html

     
  • 相关阅读:
    27_Go基础(defer)
    30_Go基础(接口)
    29_Go基础(结构体)
    关于PLSQL Developer报"动态执行表不可访问,本会话的自动统计被禁止"错的解决方法
    用JSP实现上传文件的两种方法
    rownum in ORACLE
    sql笔试语句大全
    oracle下载地址以及安装教程
    对于js中eval()函数的理解 和 写一个函数trim() 去掉字符串左右空格
    Java IO流 FileOutputStream类 和 FileInputStream类 FileReader类和FileWriter类
  • 原文地址:https://www.cnblogs.com/aikachin/p/7765846.html
Copyright © 2011-2022 走看看