zoukankan      html  css  js  c++  java
  • IDEA+MAVEN+testNG(reportNG)

    转载:http://www.cnblogs.com/aikachin/p/7765846.html

    参考:

    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

  • 相关阅读:
    高级软件工程2017第2次作业—— 个人项目:四则运算题目生成程序(基于控制台)
    高级软件工程2017第1次作业
    2017高级软件工程 课程信息
    15061009-第0次作业(阅读与感想)
    新的開始!第一次作業
    软工实践第一次作业
    OO第四单元作业总结
    OO第二单元作业总结
    OO第一单元作业总结
    Dell BOSS 卡是什么
  • 原文地址:https://www.cnblogs.com/ceshi2016/p/8442146.html
Copyright © 2011-2022 走看看