18.d5abf3da.js
8.1 KB
(window.webpackJsonp=window.webpackJsonp||[]).push([[18],{282:function(t,a,s){"use strict";s.r(a);var e=s(14),r=Object(e.a)({},(function(){var t=this,a=t.$createElement,s=t._self._c||a;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("h1",{attrs:{id:"质量保证体系"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#质量保证体系"}},[t._v("#")]),t._v(" 质量保证体系")]),t._v(" "),s("p",[t._v("通过各类型自动化工具及测试用例对代码质量进行检测")]),t._v(" "),s("h2",{attrs:{id:"团队应用现状"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#团队应用现状"}},[t._v("#")]),t._v(" 团队应用现状")]),t._v(" "),s("ul",{staticClass:"contains-task-list"},[s("li",{staticClass:"task-list-item"},[s("input",{staticClass:"task-list-item-checkbox",attrs:{checked:"",disabled:"",type:"checkbox"}}),t._v(" 语法检查工具")]),t._v(" "),s("li",{staticClass:"task-list-item"},[s("input",{staticClass:"task-list-item-checkbox",attrs:{disabled:"",type:"checkbox"}}),t._v(" 单元测试")]),t._v(" "),s("li",{staticClass:"task-list-item"},[s("input",{staticClass:"task-list-item-checkbox",attrs:{disabled:"",type:"checkbox"}}),t._v(" 端对端测试")])]),t._v(" "),s("p",[t._v("目前所有自动化检查的方式仅为手动运行检测,后续将视情况切换为强制执行方式,检测不通过则不允许编译与发行")]),t._v(" "),s("h2",{attrs:{id:"语法检查"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#语法检查"}},[t._v("#")]),t._v(" 语法检查")]),t._v(" "),s("p",[t._v("语法检查工具用于检查代码的语法是否正确、风格是否符合要求")]),t._v(" "),s("p",[t._v("JavaScript 是一个动态的弱类型语言,在开发中比较容易出错。因为没有编译程序,为了寻找 JavaScript 代码错误通常需要在执行过程中不断调试。像 ESLint 这样的可以让程序员在编码的过程中发现问题而不是在执行的过程中。")]),t._v(" "),s("h3",{attrs:{id:"使用工具"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#使用工具"}},[t._v("#")]),t._v(" 使用工具")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"https://eslint.org/",target:"_blank",rel:"noopener noreferrer"}},[t._v("ESLint"),s("OutboundLink")],1)])]),t._v(" "),s("p",[t._v("目前使用规则为宽松模式,后续将逐步增加规则要求级别")]),t._v(" "),s("h3",{attrs:{id:"运行方式"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#运行方式"}},[t._v("#")]),t._v(" 运行方式")]),t._v(" "),s("div",{staticClass:"language-bash line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-bash"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("npm")]),t._v(" run lint\n")])]),t._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[t._v("1")]),s("br")])]),s("h3",{attrs:{id:"检查结果要求"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#检查结果要求"}},[t._v("#")]),t._v(" 检查结果要求")]),t._v(" "),s("p",[t._v("ESlint 命令行输出")]),t._v(" "),s("blockquote",[s("Badge",{attrs:{text:"DONE",vertical:"middle"}}),t._v(" No lint errors found!\n")],1),t._v(" "),s("p",[t._v("代表了语法检查通过")]),t._v(" "),s("h2",{attrs:{id:"单元测试"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#单元测试"}},[t._v("#")]),t._v(" 单元测试")]),t._v(" "),s("p",[t._v("单元测试是用来对一个模块、一个函数或者一个类来进行正确性检验的测试工作,可以理解为 "),s("strong",[t._v("白盒测试")]),t._v(" 的行为。")]),t._v(" "),s("h3",{attrs:{id:"为什么要写单元测试?"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#为什么要写单元测试?"}},[t._v("#")]),t._v(" 为什么要写单元测试?")]),t._v(" "),s("p",[t._v("Web应用程序越来越复杂,这意味着有更多的可能出错。测试是帮助我们提高代码质量、降低错误的最好方法和工具之一")]),t._v(" "),s("ul",[s("li",[t._v("测试可以确保得到预期结果")]),t._v(" "),s("li",[t._v("加快开发速度")]),t._v(" "),s("li",[t._v("方便维护")]),t._v(" "),s("li",[t._v("提供用法的文档")])]),t._v(" "),s("p",[t._v("通过测试提供软件的质量,在开始的时候,可能会降低开发速度。但是从长期看,尤其是那种代码需要长期维护、不断开发的情况,测试会大大加快开发速度,减轻维护难度")]),t._v(" "),s("h3",{attrs:{id:"使用功能库"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#使用功能库"}},[t._v("#")]),t._v(" 使用功能库")]),t._v(" "),s("table",[s("thead",[s("tr",[s("th",[t._v("功能库")]),t._v(" "),s("th",[t._v("作用")])])]),t._v(" "),s("tbody",[s("tr",[s("td",[s("a",{attrs:{href:"https://mochajs.org/",target:"_blank",rel:"noopener noreferrer"}},[t._v("Mocha"),s("OutboundLink")],1)]),t._v(" "),s("td",[t._v("单元测试引擎")])]),t._v(" "),s("tr",[s("td",[s("a",{attrs:{href:"https://www.chaijs.com/",target:"_blank",rel:"noopener noreferrer"}},[t._v("Chai"),s("OutboundLink")],1)]),t._v(" "),s("td",[t._v("断言库")])]),t._v(" "),s("tr",[s("td",[s("a",{attrs:{href:"https://github.com/jsdom/jsdom",target:"_blank",rel:"noopener noreferrer"}},[t._v("JsDom"),s("OutboundLink")],1)]),t._v(" "),s("td",[t._v("虚拟浏览器容器")])]),t._v(" "),s("tr",[s("td",[s("a",{attrs:{href:"https://vue-test-utils.vuejs.org/zh/",target:"_blank",rel:"noopener noreferrer"}},[t._v("@vue/test-utils"),s("OutboundLink")],1)]),t._v(" "),s("td",[t._v("vue 官方提供单元测试工具集")])])])]),t._v(" "),s("h3",{attrs:{id:"运行方式-2"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#运行方式-2"}},[t._v("#")]),t._v(" 运行方式")]),t._v(" "),s("div",{staticClass:"language-bash line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-bash"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("npm")]),t._v(" run test:unit\n")])]),t._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[t._v("1")]),s("br")])]),s("h3",{attrs:{id:"适用范围"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#适用范围"}},[t._v("#")]),t._v(" 适用范围")]),t._v(" "),s("p",[t._v("很多时候,一些简单的功能场景,例如表单增、删、改、查等并没有编写单元测试的必要,况且编写单元测试需要不少时间成本,建议编写单元测试的场景如下")]),t._v(" "),s("ul",[s("li",[t._v("系统底层 API")]),t._v(" "),s("li",[t._v("功能封装类")]),t._v(" "),s("li",[t._v("功能组件")]),t._v(" "),s("li",[t._v("关联计算")]),t._v(" "),s("li",[t._v("业务集成联动")])]),t._v(" "),s("p",[t._v("对于功能封装函数,更是应该增加多种测试用例进行功能覆盖,对于边界测试更是其中重中之重")]),t._v(" "),s("h2",{attrs:{id:"端对端测试(end-to-end)"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#端对端测试(end-to-end)"}},[t._v("#")]),t._v(" 端对端测试(End-to-end)")]),t._v(" "),s("p",[t._v("端对端测试,简单地可以理解为站在用户角度的测试。站在用户的角度,他不需要知道软件的内部实现是怎么样的,只是使用即可;那么端对端测试模拟的就是用户的行为,只负责打开软件/浏览器,按序执行测试用例,并检查测试结果是否符合预期,它是 "),s("strong",[t._v("黑盒测试")]),t._v(" 的行为。")]),t._v(" "),s("h3",{attrs:{id:"使用功能库-2"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#使用功能库-2"}},[t._v("#")]),t._v(" 使用功能库")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"https://www.cypress.io/",target:"_blank",rel:"noopener noreferrer"}},[t._v("cypress"),s("OutboundLink")],1)])]),t._v(" "),s("h3",{attrs:{id:"运行方式-3"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#运行方式-3"}},[t._v("#")]),t._v(" 运行方式")]),t._v(" "),s("div",{staticClass:"language-bash line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-bash"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("npm")]),t._v(" run test:e2e\n")])]),t._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[t._v("1")]),s("br")])])])}),[],!1,null,null,null);a.default=r.exports}}]);