0、spring lombok json gson java commons-lang3
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version> 1.16.22</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version> 20190722</version>
</dependency>
1、httpclient cookiestore
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.12</version>
</dependency>
CookieStore cookieStore= new BasicCookieStore();
CloseableHttpClient httpClient =HttpClientBuilder.create().setDefaultCookieStore(TestConfig.cookieStore).build();
HttpPost post =new HttpPost(url);
Gson().toJson(userReq)); object >>>String
JSONObject param = new JSONObject(); param.toString(); JSONObject>>>String
StringEntity entity =new StringEntity(param.toString(),"utf-8");
post.setEntity(entity);
HttpResponse response =httpClient.execute(post);
result = EntityUtils.toString(response.getEntity(),”utf-8"); ResponseEntityProxy>>String
List resultList = Arrays.asList(result); Sring>>ArrayList
JSONArray array =new JSONArray(resultList); ArrayList >>>JSONArray
cookieStore.getCookies().get(0).getValue()
2、mybatis datasource
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version> 8.0.19</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version> 2.1.2</version>
</dependency>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/autotest"/>
<property name="username" value="spring"/>
<property name="password" value="spring"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="mapper/SQLMapper.xml"/>
</mappers>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tanzi.model">
<select id="loginCase" parameterType="Integer" resultType="com.tanzi.model.LoginCase">
select * from loginCase
where id = #{id};</select>
Reader reader= Resources.getResourceAsReader("databaseConfig.xml");
SqlSessionFactory factory=new SqlSessionFactoryBuilder().build(reader);
SqlSession sqlSession =factory.openSession(true);
return sqlSession;
3 、testng extentreports
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version> 2.41.1</version>
</dependency>
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>testng-extentsreport</artifactId>
<version> 1.3.1</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.6</version>
</dependency>
<listeners>
<listener class-name="com.tanzi.config.ExtentTestNGReportListener" />
</listeners>