3.2 xml文件的编写
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="TestGetRole" parallel="classes" thread-count="5">
<parameter name="url" value="/sys/login" />
<parameter name="objBean" value="loginIn" />
<parameter name="status" value="OK" />
<parameter name="statusCode" value="200" />
<parameter name="xmlName" value="mapRole" />
<test name="TestGetRole" preserve-order="true">
<parameter name="url" value="/json/getRoleInfo" />
<parameter name="objBean" value="GetRole" />
<parameter name="status" value="OK" />
<parameter name="statusCode" value="200" />
<parameter name="body" value="roleName" />
<classes>
<class name="com.lc.testScript.GetRoleTest">
<methods>
<include name="TestGetRole" />
<!--<include name="TestGetRole2" />-->
</methods>
</class>
</classes>
</test>
</suite>
  右键->run as ->TestNG Suite,这个场景的的测试用例可以运行了
  4、测试报告和项目组织
  测试报告这里用到第三方的包ReportNG 项目组织用Maven
<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>
..........................................
..........................................
..........................................
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<xmlFileName1>TestGetRole.xml</xmlFileName>
.................这里写testNG对应的XML名称----------------------
<xmlFileName10>TestGetUser.xml</xmlFileName>
</properties>
<dependencies>
..........................
</dependencies>
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/java/testSuites/${xmlFileName}</suiteXmlFile>
.................略............
..............这里的和properties中的xmlFileName想对应............
<suiteXmlFile>src/test/java/testSuites/${xmlFileName10}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<!-- 添加插件,添加ReportNg的监听器,修改后的TestNg的报告 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter</value>
</property>
</properties>
<workingDirectory>target/</workingDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
  [注] 因为是maven的项目所以要将testSuite的xml文件放在maven的test目录下,这样右键pom.xml文件maven test,所有的测试用例开始执行了
  测试报告

  框架目前存在的不足
  1、数据库数据校验这一块的功能还没有完善,计划用MyBatis
  2、参数使用了xml文件配置虽然灵活但有些繁琐,目前还没想到好的解决方案,testlink是否可以尝试一下呢