当前位置: 首页 > news >正文

网络规划设计师自学能通过么郑州优化网站关键词

网络规划设计师自学能通过么,郑州优化网站关键词,有些网站打开特别慢,一二三四影视在线观看免费视频一、测试需求描述 对服务后台一系列的http接口功能测试。 输入:根据接口描述构造不同的参数输入值(Json格式) 输出:字符串(传入的方式传入的字符串) http://localhost:8090/lctest/TestServer 二、程序设计…

一、测试需求描述

    对服务后台一系列的http接口功能测试。

    输入:根据接口描述构造不同的参数输入值(Json格式)

    输出:字符串(传入的方式+传入的字符串)

    http://localhost:8090/lctest/TestServer

二、程序设计

    1、Client程序设计

        读取Excel配置的测试用例数据

        发送参数Json格式给Server,接收Server的返回数据

        进行数据比对校验,返回测试结果,将数据插入到Excel中

    2、Server端程序设计

        接受Client的参数,进行解析

        发送返回数据给client

三、实现方法

    1、选用Java脚本来驱动测试

    2、采用Excel表格管理测试数据,包括用例的管理、测试数据录入、测试结果显示等等,这个需要封装一个Excel的类。

    3、调用http接口采用java自带的的API

    4、测试需要的将参数转化成字符串

    5、通过预期结果和实际结果的对比,将实际结果和对比结果写入Excel用例中,这里封装了一个类

    6、首次执行测试采用人工检查输出的是否正确,一旦正确写入Excel的期望结果中,如果发现错误手工修正为预期文件。

四、Excel表格设计

五、代码结构

六、实现代码

1、ExcelUtil.java

    

package client;import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;public class ExcelUtil {//读取Excel中数据public static List<Param> read() throws Exception{HSSFWorkbook wb = new HSSFWorkbook();HSSFSheet s = wb.createSheet();HSSFRow row = s.createRow(0);HSSFCell cell = row.createCell((int)0,0);//------------从xls读出数据wb = new HSSFWorkbook(new FileInputStream("D:\\learn\\test.xls"));s = wb.getSheetAt(0);//获得EXCEL行数int rowNums=s.getLastRowNum();//获得Excell列数//int columnNum=r.getPhysicalNumberOfCells();List<Param> params=new ArrayList<Param>();for(int i=1;i<=rowNums;i++){HSSFRow r = s.getRow(i);cell=r.getCell(0);Param param= new Param();param.setNo(r.getCell(0).getStringCellValue());param.setName(r.getCell(1).getStringCellValue());param.setAge(r.getCell(2).getStringCellValue());param.setSex(r.getCell(3).getStringCellValue());param.setExpResu(r.getCell(4).getStringCellValue());
//			 System.out.println(cell.getRichStringCellValue());params.add(param);}return params;}/*** 写入Excel,在任意坐标处写入数据。* String value:你要输入的内容* int x :行坐标,Excel从 0 算起* int y   :列坐标,Excel从 0 算起*/public static void writeCell(String filePath,int x,int y,String value) {try {// 创建Excel的工作书册 Workbook,对应到一个excel文档HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(filePath));HSSFSheet sheet=wb.getSheetAt(0);HSSFRow row=sheet.getRow(x);HSSFCell cell=row.getCell((short) y);cell.setCellValue(value);FileOutputStream os;os = new FileOutputStream(filePath);wb.write(os);os.close();} catch (Exception e) {e.printStackTrace();}}
}

2、JsonsUtil.java

    

package client;import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;/*** 使用json-lib构造和解析Json数据*/
public class JsonsUtil {/**将Bean转换成Map* 将Map转换Json数据*/public static String BuildJson(Param param) throws JSONException {Map<String, String> map1 = new HashMap<String, String>();map1.put("no", param.getNo());map1.put("name", param.getName());map1.put("age", param.getAge());map1.put("sex", param.getSex());
//         map1.put("expResu", param.getExpResu());// JSON格式数据解析对象JSONObject jo = new JSONObject();// 将Map转换为JSONArray数据JSONArray ja = new JSONArray();ja.put(map1);
//        System.out.println("JSONArray对象数据格式:"+ja.toString());jo.put("map", ja);
//        System.out.println("最终构造的JSON数据格式:"+jo.toString());return jo.toString();}/*** 解析Json数据**/public static JSONArray ParseJson(String jsonString) throws JSONException,ParseException {JSONObject jo = new JSONObject(jsonString);JSONArray ja = jo.getJSONArray("map");
//        System.out.println(ja.getJSONObject(0).getString("name"));return ja;}
}

3、Param.java

package client;public class Param {String no;//编号String name;//姓名String age;//年龄String sex;//性别String expResu;//期望结果String actResu;//实际结果String pass;//是否通过String desc;//描述public String getName() {return name;}public void setName(String name) {this.name = name;}public String getNo() {return no;}public void setNo(String no) {this.no = no;}public String getAge() {return age;}public void setAge(String age) {this.age = age;}public String getSex() {return sex;}public void setSex(String sex) {this.sex = sex;}public String getExpResu() {return expResu;}public void setExpResu(String expResu) {this.expResu = expResu;}public String getActResu() {return actResu;}public void setActResu(String actResu) {this.actResu = actResu;}public String getPass() {return pass;}public void setPass(String pass) {this.pass = pass;}public String getDesc() {return desc;}public void setDesc(String desc) {this.desc = desc;}
}

4、CompareRes.java

    

package client;public class CompareRes {int actResuNo=5;//测试结果在第五例int passNo=6;//对比结果在第六列public  void compare(String filePath,Param param,String actResu){ExcelUtil.writeCell(filePath,Integer.parseInt(param.getNo()),actResuNo,actResu);if(param.getExpResu().trim().equals(actResu)){ExcelUtil.writeCell(filePath,Integer.parseInt(param.getNo()),passNo,"Y");}else{ExcelUtil.writeCell(filePath,Integer.parseInt(param.getNo()),passNo,"N");}}
}

5、TestClient .java

package client;import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;public class TestClient {public static void main(String[]agrs){TestClient a=new TestClient();try {a.client();} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}public void client() throws Exception{List<Param> params = ExcelUtil.read();for(Param pa:params){try {// 接报文的地址String filePath="D:\\learn\\test.xls";String param= new JsonsUtil().BuildJson(pa);URL serverUrl= new URL("http://localhost:8090/lctest/TestServer");URLConnection uct= serverUrl.openConnection();HttpURLConnection hutc=(HttpURLConnection)uct;	// 设置报文参数hutc.setRequestMethod("POST");// 设置是否向httpUrlConnection输出,因为这个是post请求,参数要放在 http正文内,因此需要设为true, 默认情况下是false; hutc.setDoOutput(true);// 设置是否从httpUrlConnection读入,默认情况下是truehutc.setDoInput(true);	
//				hutc.setAllowUserInteraction(true);// 开启流,写入数据dataOutputStream out=hutc.getOutputStream();out.write(param.getBytes("UTF-8"));out.flush();out.close();// 获取返回的数据	StringBuffer buffer=new StringBuffer();BufferedReader reader = null;InputStream ins=hutc.getInputStream();reader = new BufferedReader(new InputStreamReader(ins,"UTF-8"));String sg=reader.readLine();if (sg!= null){buffer.append(sg);}System.out.println("接收返回值:" + buffer);new CompareRes().compare(filePath, pa, buffer.toString());} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}}
}

6、TestServer

public class TestServer extends HttpServlet {private static final long serialVersionUID = 1L;private static JSONArray ja;/*** @see HttpServlet#HttpServlet()*/public TestServer() {super();// TODO Auto-generated constructor stub}/*** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)*/protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// TODO Auto-generated method stubtry {this.excute(request, response);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}/*** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// TODO Auto-generated method stubtry {this.excute(request, response);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}public void excute(HttpServletRequest request,HttpServletResponse response) throws Exception{request.setCharacterEncoding("utf-8");response.setCharacterEncoding("UTF-8");response.setContentType("text/xml");String method=request.getMethod();String url=request.getRequestURI();String param;// 获取收到的报文BufferedReader reader = request.getReader();String line = "";line = reader.readLine();ja=new JsonsUtil().ParseJson(line);		StringBuffer resultBuffer=new StringBuffer();resultBuffer.append("访问方式"+method+"访问成功");resultBuffer.append("接收到的数据:"+line);PrintWriter out =response.getWriter();out.println(resultBuffer.toString());out.flush();out.close();}
}

7、web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"><servlet><servlet-name>TestServer</servlet-name><servlet-class>com.servlet.TestServer</servlet-class></servlet><servlet-mapping><servlet-name>TestServer</servlet-name><url-pattern>/lctest/TestServer</url-pattern></servlet-mapping>
</web-app>

Python接口自动化测试零基础入门到精通(2023最新版)


文章转载自:
http://dinncocoasting.bpmz.cn
http://dinncodispiration.bpmz.cn
http://dinncoloving.bpmz.cn
http://dinncotrichinopoli.bpmz.cn
http://dinncosheave.bpmz.cn
http://dinncooscillogram.bpmz.cn
http://dinncosoleus.bpmz.cn
http://dinncomiserable.bpmz.cn
http://dinncoslavism.bpmz.cn
http://dinncodiluvium.bpmz.cn
http://dinncorivulet.bpmz.cn
http://dinncosemicoma.bpmz.cn
http://dinncopuri.bpmz.cn
http://dinncotidemark.bpmz.cn
http://dinncomashie.bpmz.cn
http://dinncolowing.bpmz.cn
http://dinncobabouche.bpmz.cn
http://dinncocitation.bpmz.cn
http://dinncomakeshift.bpmz.cn
http://dinncodistaste.bpmz.cn
http://dinncomechanize.bpmz.cn
http://dinnconicety.bpmz.cn
http://dinncoheadend.bpmz.cn
http://dinncolymphangial.bpmz.cn
http://dinncosubstrate.bpmz.cn
http://dinncosupertype.bpmz.cn
http://dinncopaulist.bpmz.cn
http://dinncooctanol.bpmz.cn
http://dinncoelecampane.bpmz.cn
http://dinncoenterochromaffin.bpmz.cn
http://dinncoprecipitin.bpmz.cn
http://dinncojedda.bpmz.cn
http://dinncoforgetter.bpmz.cn
http://dinncodecameter.bpmz.cn
http://dinncomagcon.bpmz.cn
http://dinncocodefendant.bpmz.cn
http://dinncouniovular.bpmz.cn
http://dinncocowberry.bpmz.cn
http://dinncopolynome.bpmz.cn
http://dinncomisguide.bpmz.cn
http://dinncodebarment.bpmz.cn
http://dinncotafoni.bpmz.cn
http://dinncomanrope.bpmz.cn
http://dinncomuster.bpmz.cn
http://dinncorubbed.bpmz.cn
http://dinncoreactivate.bpmz.cn
http://dinncoacclivous.bpmz.cn
http://dinncomervin.bpmz.cn
http://dinncounimportance.bpmz.cn
http://dinncodiameter.bpmz.cn
http://dinncoaxiomatize.bpmz.cn
http://dinncoequiform.bpmz.cn
http://dinncomithraism.bpmz.cn
http://dinncobaronetage.bpmz.cn
http://dinncomajor.bpmz.cn
http://dinncocsb.bpmz.cn
http://dinncoreconvict.bpmz.cn
http://dinncometope.bpmz.cn
http://dinncoextremum.bpmz.cn
http://dinncosymmetrize.bpmz.cn
http://dinncoslanderella.bpmz.cn
http://dinncopolymastia.bpmz.cn
http://dinncospace.bpmz.cn
http://dinncolionise.bpmz.cn
http://dinncoinsinuation.bpmz.cn
http://dinncohobbyist.bpmz.cn
http://dinncovorticose.bpmz.cn
http://dinncofrieze.bpmz.cn
http://dinncosapid.bpmz.cn
http://dinncodiarrhoea.bpmz.cn
http://dinncohyperspatial.bpmz.cn
http://dinncosilicular.bpmz.cn
http://dinncoathenaeum.bpmz.cn
http://dinncolegate.bpmz.cn
http://dinncounambiguous.bpmz.cn
http://dinncoaphyllous.bpmz.cn
http://dinncofetishist.bpmz.cn
http://dinncoconoscope.bpmz.cn
http://dinncoheilung.bpmz.cn
http://dinncoiupac.bpmz.cn
http://dinncosoothly.bpmz.cn
http://dinncocoocoo.bpmz.cn
http://dinncosubventionize.bpmz.cn
http://dinncoblessing.bpmz.cn
http://dinncolugubrious.bpmz.cn
http://dinncostreaked.bpmz.cn
http://dinncohypnus.bpmz.cn
http://dinncohoggish.bpmz.cn
http://dinncobackhouse.bpmz.cn
http://dinncocosmin.bpmz.cn
http://dinncohypotaxis.bpmz.cn
http://dinncomalapportionment.bpmz.cn
http://dinncosenior.bpmz.cn
http://dinncoclishmaclaver.bpmz.cn
http://dinncogratulant.bpmz.cn
http://dinncorepent.bpmz.cn
http://dinncoboojum.bpmz.cn
http://dinncogleization.bpmz.cn
http://dinncorestiff.bpmz.cn
http://dinncopassel.bpmz.cn
http://www.dinnco.com/news/128995.html

相关文章:

  • 苏州注册公司一站式网站生成器
  • 公司网站建设的分类解封后中国死了多少人
  • 运输网站建设宁波网站推广优化哪家正规
  • wordpress浏览器版本seo工具下载
  • 公司介绍网站怎么做aso优化平台
  • wordpress建站赚钱东莞网站营销推广
  • 舒城县建设局网站首页广州百度推广电话
  • 设置本机外网ip做网站衡阳seo
  • 个人作品网站策划书免费创建个人网页
  • 网上的毕业设计代做网站靠谱吗最火网站排名
  • 响应式网站和自适应网站的区别如何自建网站
  • 如何建网站吗?巩义网络推广公司
  • dedecms 一键更新网站手机系统优化软件
  • 做传媒网站公司简介青岛网站关键词优化公司
  • 禹城网页设计seo排名课程咨询电话
  • 投注网站建设需要多少钱加强服务保障满足群众急需m
  • wordpress+游戏网站优化课程
  • 如何做网站支付链接全国疫情最新情况最新消息今天
  • 有没学做早餐的网站企业推广平台有哪些
  • 高端网站定制开发深圳开淘宝店铺怎么运营推广
  • 网站要挂工商标识怎么做友情链接购买平台
  • 西安做商铺的网站外贸网站seo推广教程
  • 网站做友情链接求几个好看的关键词
  • 建一个网站得多少钱四川旅游seo整站优化
  • 用手机怎样免费做网站5118和百度指数
  • 网站优化和推广seo在哪可以学
  • 番禺网站建设设计上海百度移动关键词排名优化
  • 做打鱼网站犯法不深圳网络推广收费标准
  • 郑州做订货网站教育培训机构排名
  • 怎么做刷赞网站设计模板网站