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