-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
96 changed files
with
4,012 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,8 @@ _book/ | |
book.pdf | ||
book.epub | ||
book.mobi | ||
sample/smashtest | ||
.DS_Store | ||
smashtest | ||
package-lock.json | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,48 @@ | ||
# My Awesome Book | ||
# Smashtest介绍 | ||
|
||
> ###### Smashtest是一种快速描述和部署测试用例的语言。 | ||
它以树形结构写测试用例,极大的加速你的自动化测试用例速度;树代表我们在测试时的想法。它们允许我们列出从任何给定点分支的所有排列。 | ||
|
||
``` | ||
npm i -g smashtest | ||
``` | ||
|
||
#####  | ||
|
||
##### 截图效果 | ||
|
||
|  |  | | ||
| ---: | :--- | | ||
| | | | ||
|
||
##### **测试用例** | ||
|
||
> 注: 以缩进为4个空格作为每行的约束 | ||
```smash | ||
Open Chrome | ||
Open Firefox | ||
Open Safari | ||
Navigate to 'site.com' | ||
Click 'Sign In' | ||
Type {username:} into 'username box' | ||
{username} is 'joe' | ||
{username} is 'bob' | ||
{username} is 'mary' | ||
Verify success | ||
{username} is 'baduser' | ||
Verify error | ||
``` | ||
|
||
上述语句执行时case效果具体底层代码逻辑 | ||
|
||
 | ||
|
||
This file file serves as your book's preface, a great place to describe your book's content and ideas. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,47 @@ | ||
# Table of content | ||
# Summary | ||
|
||
* [介绍](README.md) | ||
* [开始](chapter1-setup.md) | ||
* [写第一个用例](chapter1-writecase.md) | ||
* [调试与学习](chapter1-debugandlearn.md) | ||
* [基础语言语法](charpter1-syntax.md) | ||
* [运行测试](yun-xing-ce-shi.md) | ||
* [命令行选项](yun-xing-ce-shi/ming-ling-xing-xuan-xiang.md) | ||
* [选择性测试运行](yun-xing-ce-shi/xuan-ze-xing-ce-shi-yun-xing.md) | ||
* [CI/CD集成](yun-xing-ce-shi/cicdji-cheng.md) | ||
* [运行报告](yun-xing-bao-gao.md) | ||
* [语言](yu-yan.md) | ||
* [步骤块](yu-yan/bu-zou-kuai.md) | ||
* [文本步骤](yu-yan/wen-ben-bu-zou.md) | ||
* [函数](yu-yan/han-shu.md) | ||
* [变量](yu-yan/bian-liang.md) | ||
* [代码块](yu-yan/dai-ma-kuai.md) | ||
* [代码引用](yu-yan/dai-ma-yin-yong.md) | ||
* [顺序执行](yu-yan/shun-xu-zhi-xing.md) | ||
* [串行](yu-yan/chuan-xing.md) | ||
* [注释](yu-yan/zhu-shi.md) | ||
* [分组与频率](yu-yan/fen-zu-yu-pin-lv.md) | ||
* [条件测试](yu-yan/tiao-jian-ce-shi.md) | ||
* [跳过](yu-yan/tiao-guo.md) | ||
* [折叠](yu-yan/zhe-die.md) | ||
* [唯一](yu-yan/wei-yi.md) | ||
* [调试](yu-yan/diao-shi.md) | ||
* [钩子](yu-yan/gou-zi.md) | ||
* [用户界面测试](uice-shi.md) | ||
* [浏览器和设备](uice-shi/liu-lan-qi-he-she-bei.md) | ||
* [浏览器步骤](uice-shi/liu-lan-qi-bu-zou.md) | ||
* [验证步骤](uice-shi/yan-zheng-bu-zou.md) | ||
* [网络设置和流量](uice-shi/wang-luo-he-liu-liang.md) | ||
* [模拟时间和地理位置](uice-shi/mo-ni-shi-jian-he-di-li-wei-zhi.md) | ||
* [模拟API](uice-shi/mo-niapi.md) | ||
* [元素查找器](uice-shi/yuan-su-cha-zhao-qi.md) | ||
* [默认元素查找器属性](uice-shi/mo-ren-yuan-su-cha-zhao-qi-shu-xing.md) | ||
* [截屏](uice-shi/jie-ping.md) | ||
* [代码引用](uice-shi/dai-ma-yin-yong.md) | ||
* [API测试](apice-shi.md) | ||
* [请求](apice-shi/qing-qiu.md) | ||
* [响应与校验](apice-shi/xiang-ying-yu-xiao-yan.md) | ||
* [REPL](repl.md) | ||
* [安装包](an-zhuang-bao.md) | ||
* [联系我们](lian-xi-wo-men.md) | ||
|
||
* [First Chapter](chapter1.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
### 安装包 | ||
|
||
> 例子: sample/other/require-package.smash | ||
### 做一个包 | ||
|
||
通过分发包来共享步骤和功能: | ||
|
||
1. 在JS文件中实现功能。 | ||
2. 通过NPM注册表将该文件作为[NPM包](https://docs.npmjs.com/packages-and-modules/)分发 | ||
3. 用户可以直接从您下载或复制到其.smash文件中的简单函数声明: | ||
|
||
``` | ||
* My awesome function { | ||
i('my_awesome_npm_package').myAwesomeFunction(); // i() is similar to require() | ||
} | ||
``` | ||
|
||
### 使用一个包 | ||
|
||
安装要用的包 | ||
|
||
1. 将包安装到同级目录或者上级或者全局安装。 | ||
2. 将上述函数声明复制到其中一个文件中,或者下载一个.smash文件,该文件中已经有声明。确保它在运行测试时与其他.smash文件一起运行。 | ||
3. 现在就可以各处使用它了 | ||
|
||
``` | ||
My awesome function | ||
``` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# API测试 | ||
|
||
SmashTest内置一个HTTP API测试的包。本节讨论此包提供的JS函数。 | ||
|
||
例子 | ||
|
||
``` | ||
Book room for '0' nights | ||
Book room for '1' nights | ||
Book room for '2' nights | ||
Verify success | ||
Book room for '100' nights | ||
Verify error | ||
* Book room for {{n}} nights { | ||
await api.get('https://api.com/book/{{n}}'); | ||
} | ||
* Verify success { | ||
response.verify({ statusCode: 200 }); | ||
} | ||
* Verify error { | ||
response.verify({ statusCode: { $min: 400, $max: 499 } }); | ||
} | ||
``` | ||
|
||
``` | ||
Make a request { | ||
await api.post({ | ||
url: 'https://{host}/endpoint', | ||
headers: { | ||
'content-type': 'application/json' | ||
}, | ||
body: { | ||
id: 123, | ||
user: 'jerry' | ||
}, | ||
timeout: 1500 | ||
}); | ||
} | ||
Verify response { | ||
response.verify({ | ||
statusCode: 200, | ||
headers: { | ||
'content-type': 'text/html; charset=utf-8' | ||
}, | ||
error: null, | ||
body: { | ||
id: 123, | ||
user: 'jerry', | ||
results: [ | ||
'$anyOrder', // loose-matching of a JSON response body | ||
{ | ||
cost: { $min: 10 }, | ||
items: 6, | ||
name: { $contains: 'apples' } | ||
}, | ||
{ | ||
cost: { $min: 15 }, | ||
items: 7, | ||
name: { $typeof: 'string', $contains: 'berries' } | ||
} | ||
] | ||
} | ||
}); | ||
} | ||
``` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# 请求 | ||
|
||
> 详情查看[request文档](https://github.com/request/request) | ||
### request\(\) | ||
|
||
``` | ||
await request('https://api.com/endpoint'); // GET by default | ||
``` | ||
|
||
``` | ||
await request({ | ||
method: 'GET', // GET, POST, PUT, PATCH, DELETE, HEAD, or OPTIONS | ||
url: 'https://api.com/endpoint', | ||
timeout: 1500 // setting timeout (in ms) is recommended | ||
// otherwise the default OS TCP timeout applies, | ||
// and that can be up to 2 minutes | ||
}); | ||
``` | ||
|
||
### get\(\) | ||
|
||
``` | ||
await get('https://api.com/endpoint'); | ||
``` | ||
|
||
``` | ||
await get({ | ||
url: 'https://api.com/endpoint', | ||
headers: { | ||
'content-type': 'text/plain' | ||
}, | ||
timeout: 1500 | ||
}); | ||
``` | ||
|
||
### post\(\) | ||
|
||
await post({ | ||
url: 'https://api.com/endpoint', | ||
headers: { | ||
'content-type': 'text/plain' | ||
}, | ||
body: `body goes here`, | ||
timeout: 1500 | ||
}); | ||
|
||
``` | ||
// JSON body | ||
await post({ | ||
url: 'https://api.com/endpoint', | ||
body: { | ||
something: true | ||
}, | ||
json: true, // converts body to json and sets content-type header | ||
timeout: 1500 | ||
}); | ||
``` | ||
|
||
### put\(\) | ||
|
||
await put({ | ||
url: 'https://api.com/endpoint', | ||
headers: { | ||
'content-type': 'text/plain' | ||
}, | ||
body: `body goes here`, | ||
timeout: 1500 | ||
}); | ||
|
||
### patch\(\) | ||
|
||
await patch({ | ||
url: 'https://api.com/endpoint', | ||
headers: { | ||
'content-type': 'text/plain' | ||
}, | ||
body: `body goes here`, | ||
timeout: 1500 | ||
}); | ||
|
||
### del\(\) | ||
|
||
await del({ | ||
url: 'https://api.com/endpoint', | ||
headers: { | ||
'content-type': 'text/plain' | ||
}, | ||
body: `body goes here`, | ||
timeout: 1500 | ||
}); | ||
|
||
### head\(\) | ||
|
||
``` | ||
await head('https://api.com/endpoint'); | ||
``` | ||
|
||
### options\(\) | ||
|
||
``` | ||
await options('https://api.com/endpoint'); | ||
``` | ||
|
||
### api.defaults\(\) | ||
|
||
``` | ||
api.defaults({proxy: 'http://localproxy.com'}); // see request's documentation for details | ||
``` | ||
|
||
### Cookies | ||
|
||
``` | ||
// create cookies | ||
let jar = api.jar(); | ||
let cookie1 = api.cookie('key1=value1'); | ||
let cookie2 = api.cookie('key2=value2'); | ||
let url = 'http://site.com'; | ||
jar.setCookie(cookie1, url); | ||
jar.setCookie(cookie2, url); | ||
// make a request that includes the cookies | ||
await get({url: 'http://site.com/endpoint', jar: jar}); | ||
``` | ||
|
||
|
||
|
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"pluginsConfig": { | ||
"code": { | ||
"copyButtons": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# 调试与学习 | ||
|
||
### 尝试调试技能 | ||
|
||
``` | ||
Open Chrome | ||
Navigate to 'google.com' | ||
~ Type 'hello world[enter]' into 'input[name=q]' | ||
Type 'hello universe[enter]' into 'input[name=q]' | ||
``` | ||
|
||
在需要调试的分支加入~,这个分支会被隔离运行在无头浏览器模式下,并暂停到~之前的执行行,可以在控制控制台中操作执行步骤. | ||
|
||
此模式称为repl。它对学习和调试非常有用。 | ||
|
||
### 开发技能 | ||
|
||
使用~实际上是一种推荐的测试开发技术: | ||
|
||
1. 写一个步骤 | ||
2. 在它的末端放一个~ | ||
|
||
3. 运行smashtest,它将浏览器运行到该行 | ||
|
||
4. 提出所有可以从该点分支的排列(使用浏览器作为引导) | ||
|
||
5. 用~缩进的步骤将被列出来 | ||
|
||
6. 重复用在console中调试 | ||
|
||
|
||
|
Oops, something went wrong.