docs: 更新测试集合的变量参数部分文档

This commit is contained in:
wenbo.dong 2017-10-18 16:29:18 +08:00
parent 78cb3ac92f
commit edc8f23381
17 changed files with 69 additions and 27 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

View File

@ -20,16 +20,19 @@ Mock 参数每次请求都会生成随机字符串
#### 变量参数
<img class="doc-img" style="width:100%" src="./images/usage/mock-var-param.jpg" />
YApi 提供了强大的变量参数功能,你可以在测试的时候使用 `前面接口的返回值` 作为 `后面接口的参数`,即使接口之间存在依赖,也可以 **一键测试~**
例如:现有两个接口,分别是“导航标题”和“文章列表”
$.371.data._id
<img class="doc-img" style="width: 678px;" src="./images/usage/case_key_list.png" />
$. 是使用动态变量的标志
371 是用例 key ,可在用例列表查看到
data._id 是接口返回数据指向的实际字段
文章列表接口需要传参数: `当前标题(id)`,而这个 id 需要通过 `导航标题` 的返回值获取,这时应在 `文章列表` 的参数输入框中根据前者的 key 找到对应 id。
`导航标题` 的返回值:
<img class="doc-img" style="width: 122px;" src="./images/usage/case_key_res.png" />
`文章列表` 的参数配置:
<img class="doc-img" style="width: 682px;" src="./images/usage/case_key_query.png" />
$. 是使用动态变量的标志,**$.269 即表示 key 值为 269 的用例返回的数据**。
> Tips: 上下拖动测试集合的列表项可以调整测试的顺序。

View File

@ -4292,7 +4292,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#16" target="_blank">./server/controllers/interfaceCol.js:16</a>
<a href="./static/server/controllers/interfaceCol.js.html#17" target="_blank">./server/controllers/interfaceCol.js:17</a>
</p>
@ -4354,7 +4354,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#47" target="_blank">./server/controllers/interfaceCol.js:47</a>
<a href="./static/server/controllers/interfaceCol.js.html#48" target="_blank">./server/controllers/interfaceCol.js:48</a>
</p>
@ -4440,7 +4440,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#105" target="_blank">./server/controllers/interfaceCol.js:105</a>
<a href="./static/server/controllers/interfaceCol.js.html#106" target="_blank">./server/controllers/interfaceCol.js:106</a>
</p>
@ -4502,7 +4502,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#158" target="_blank">./server/controllers/interfaceCol.js:158</a>
<a href="./static/server/controllers/interfaceCol.js.html#159" target="_blank">./server/controllers/interfaceCol.js:159</a>
</p>
@ -4684,7 +4684,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#298" target="_blank">./server/controllers/interfaceCol.js:298</a>
<a href="./static/server/controllers/interfaceCol.js.html#299" target="_blank">./server/controllers/interfaceCol.js:299</a>
</p>
@ -4854,7 +4854,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#367" target="_blank">./server/controllers/interfaceCol.js:367</a>
<a href="./static/server/controllers/interfaceCol.js.html#368" target="_blank">./server/controllers/interfaceCol.js:368</a>
</p>
@ -4916,7 +4916,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#426" target="_blank">./server/controllers/interfaceCol.js:426</a>
<a href="./static/server/controllers/interfaceCol.js.html#435" target="_blank">./server/controllers/interfaceCol.js:435</a>
</p>
@ -4990,7 +4990,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#468" target="_blank">./server/controllers/interfaceCol.js:468</a>
<a href="./static/server/controllers/interfaceCol.js.html#477" target="_blank">./server/controllers/interfaceCol.js:477</a>
</p>
@ -5050,7 +5050,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#500" target="_blank">./server/controllers/interfaceCol.js:500</a>
<a href="./static/server/controllers/interfaceCol.js.html#509" target="_blank">./server/controllers/interfaceCol.js:509</a>
</p>

View File

@ -170,11 +170,18 @@
<p>测试完成之后,点击报告查看该次请求的结果</p>
<h2 class="subject" id="编辑测试用例">编辑测试用例 <a class="hashlink" href="#编辑测试用例">#</a></h2><h3 class="subject" id="Mock参数">Mock参数 <a class="hashlink" href="#Mock参数">#</a></h3><p>Mock 参数每次请求都会生成随机字符串</p>
<p><img class="doc-img" style="width:100%" src="./images/usage/case-edit.jpg" /></p>
<h4 class="subject" id="变量参数">变量参数 <a class="hashlink" href="#变量参数">#</a></h4><p><img class="doc-img" style="width:100%" src="./images/usage/mock-var-param.jpg" /></p>
<pre><code> $.<span class="token number">371</span>.data._id
</code></pre><p>$. 是使用动态变量的标志</p>
<p>371 是用例 key ,可在用例列表查看到</p>
<p>data._id 是接口返回数据指向的实际字段</p>
<h4 class="subject" id="变量参数">变量参数 <a class="hashlink" href="#变量参数">#</a></h4><p>YApi 提供了强大的变量参数功能,你可以在测试的时候使用 <code>前面接口的返回值</code> 作为 <code>后面接口的参数</code>,即使接口之间存在依赖,也可以 <strong>一键测试~</strong></p>
<p>例如:现有两个接口,分别是“导航标题”和“文章列表”</p>
<p><img class="doc-img" style="width: 678px;" src="./images/usage/case_key_list.png" /></p>
<p>文章列表接口需要传参数: <code>当前标题(id)</code>,而这个 id 需要通过 <code>导航标题</code> 的返回值获取,这时应在 <code>文章列表</code> 的参数输入框中根据前者的 key 找到对应 id。</p>
<p><code>导航标题</code> 的返回值:
<img class="doc-img" style="width: 122px;" src="./images/usage/case_key_res.png" /></p>
<p><code>文章列表</code> 的参数配置:
<img class="doc-img" style="width: 682px;" src="./images/usage/case_key_query.png" />
$. 是使用动态变量的标志,<strong>$.269 即表示 key 值为 269 的用例返回的数据</strong></p>
<blockquote>
<p>Tips: 上下拖动测试集合的列表项可以调整测试的顺序。</p>
</blockquote>
</div>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

View File

@ -86,6 +86,24 @@
<nav class="docs-sidebar hidden-print hidden-xs hidden-sm">
<ul class="nav docs-sidenav">
<!-- <li > -->
<li >
<a href="#1.1.2">1.1.2</a>
</li>
<ul class="nav docs-sidenav-extend" >
<li >
<a href="#Features">Features</a>
</li>
<li >
<a href="#Bug_Fixed">Bug Fixed</a>
</li>
</ul>
<!-- <li > -->
<li >
@ -156,7 +174,11 @@
<div class="content-right markdown-body use-sidebar" role="main">
<h2 class="subject" id="1.1.1">1.1.1 <a class="hashlink" href="#1.1.1">#</a></h2><h3 class="subject" id="Features">Features <a class="hashlink" href="#Features">#</a></h3><ul>
<h2 class="subject" id="1.1.2">1.1.2 <a class="hashlink" href="#1.1.2">#</a></h2><h3 class="subject" id="Features">Features <a class="hashlink" href="#Features">#</a></h3><ul>
<li>接口运行增加了 query 和 body 的 enable 选项,可选择是否请求该字段</li><li>Mock 支持了时间戳占位符 @timestamp</li></ul>
<h3 class="subject" id="Bug_Fixed">Bug Fixed <a class="hashlink" href="#Bug_Fixed">#</a></h3><ul>
<li>修复了接口集运行功能会忽略 domain path 的 bug</li></ul>
<h2 class="subject" id="1.1.1">1.1.1 <a class="hashlink" href="#1.1.1">#</a></h2><h3 class="subject" id="Features">Features <a class="hashlink" href="#Features">#</a></h3><ul>
<li>添加插件开发文档</li><li>接口和测试用例可拖动</li><li>优化动态提示</li></ul>
<h3 class="subject" id="Bug_Fixed">Bug Fixed <a class="hashlink" href="#Bug_Fixed">#</a></h3><ul>
<li>修复接口状态将接口方法重置为 get</li><li>环境配置域名带 path 无效</li><li>修复Swagger数据导入分类 bug</li><li>MockServer 支持 CORS 跨域</li><li>优化JSON-SCHEMA转化为JSON的逻辑由原来随机转换不被required字段改为转换全部字段</li><li>修复了项目成员无法看到该项目的Bug</li><li>修复了无法查看公共项目的Bug</li><li>优化了部分样式和交互</li></ul>

View File

@ -8,6 +8,7 @@ $(document).ready(function() {
var $versionSelector = $('.version-selector');
var $versionMask = $('.m-version-mask');
var isPanelHide = true;
var winWidth = $(window).width();
var h2 = $('.content-right').find('h2');
var h3 = $('.content-right').find('h3');
var a = $('.content-left').find('a');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,6 +31,7 @@ const interfaceModel = require('../models/interface.js');
const projectModel = require('../models/project.js');
const baseController = require('./base.js');
const yapi = require('../yapi.js');
const _ = require('underscore');
class interfaceColController extends baseController{
constructor(ctx) {
@ -433,6 +434,11 @@ class interfaceColController extends baseController{
}
}
/**
*
* @param {*} params 接口定义的参数
* @param {*} val 接口case 定义的参数值
*/
handleParamsValue(params, val){
let value = {};
try{
@ -447,6 +453,9 @@ class interfaceColController extends baseController{
params.forEach((item, index)=>{
if(!value[item.name] || typeof value[item.name] !== 'object') return null;
params[index].value = value[item.name].value;
if(!_.isUndefined(value[item.name].enable)){
params[index].enable = value[item.name].enable
}
})
return params;
}

View File

@ -636,7 +636,7 @@ class projectController extends baseController {
let result = await this.Model.up(id, data);
let username = this.getUsername();
yapi.commons.saveLog({
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了项目 <a href="/user/profile/${id}}">${projectData.name}</a>`,
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了项目 <a href="/project/${id}/interface/api}">${projectData.name}</a>`,
type: 'project',
uid: this.getUid(),
username: username,
@ -687,7 +687,7 @@ class projectController extends baseController {
let result = await this.Model.up(id, data);
let username = this.getUsername();
yapi.commons.saveLog({
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了项目 <a href="/user/profile/${id}">${projectData.name}</a> 的环境`,
content: `<a href="/user/profile/${this.getUid()}">${username}</a> 更新了项目 <a href="/project/${id}/interface/api">${projectData.name}</a> 的环境`,
type: 'project',
uid: this.getUid(),
username: username,