大家好,今天我有个好消息:一个用于管理和运行Web服务验收测试的项目at2k的beta版已经发布。让我们看一下它的主要功能,也可以在此处查看。
介绍
AT2K是一个以Golang(用于后端语言)和Angular(用于客户端)编写的开源项目。主要思想和目标是允许用户(程序员,QA工程师,甚至可能是经理)以接近其主题领域的语言编写和运行测试。
几个例子
在开始查看UI和用于自定义测试的各种选项之前,让我向您展示一个应被测试和直接测试的服务示例。
因此,服务实现(node.js):
import express from 'express';
import uuid4 from 'uuid4';
const app = express();
const users = express.Router();
const port = process.env.PORT || 4444;
let usersRepository = [];
app.use(express.json());
app.use('/api/v1/user', users);
function resetRepository() {
usersRepository = [
{hash: uuid4(), name: 'John'},
{hash: uuid4(), name: 'Nick'}
];
}
users.get('/:hash', (req, res) => {
const user = usersRepository.find(u => u.hash === req.params.hash);
if (user) {
res.status(200).send({
status: 'ok',
data: user
});
} else {
res.status(200).send({
status: 'error',
data: 'user-not-found'
});
}
});
users.post('/', (req, res) => {
const { name } = req.body;
const hash = uuid4();
usersRepository.push({
hash, name
});
res.status(200).send({status: 'ok', hash});
});
app.listen(port, () => {
resetRepository();
console.log(`Stub AT2K is available on localhost:${port}`);
});
事不宜迟,以下是一些测试:
BEGIN
createUserResponse = CREATE USER {"name": "Joe"}
ASSERT createUserResponse.status EQUALS ok
userResponse = GET USER ${createUserResponse.hash}
ASSERT userResponse.status EQUALS ok
ASSERT userResponse.data.name EQUALS Joe
ASSERT userResponse.data.hash EQUALS ${createUserResponse.hash}
END
BEGIN
userResponse = GET USER not-exists-hash
ASSERT userResponse.status EQUALS error
ASSERT userResponse.data EQUALS user-not-found
END
如您所见,一切都非常简单。
从哪里开始
首先,我们需要通过以下链接创建一个帐户,然后输入我们要使用的用户名和密码。
.
, ,
- ( ):
, ,
, :
BEGIN
createUserResponse = CREATE USER {"name": "Joe"}
END
- createUserResponse – ,
- CREATE –
- USER – ,
- {"name": "Joe"} –
, -
- ,
, . Create object :
. USER.
, Create, :
, 2 – GET CREATE. GET. (. ) :
Add command , :
Create ( , .. ).
CREATE:
, :
.
-
-. , ngrok.
node.js:
mkdir at2k-stub && cd at2k-stub
npm init -y
npm i express uuid4
touch index.js
index.js
node .
ngrok, - :
ngrok http 4444
, , , . , General settings Base URLs. Base URL http://56dd9be41097.ngrok.io Choose all:
Update .
, 1 – . (, get_create_tests.txt) . , Run tests, Tests file , . Run tests , , :
, .
?
, , (USER), , .
欢迎提出任何改进项目的建议-我在这里获得反馈。
如果有人决定研究存储库中的代码并提出改进建议或意见,我也会很高兴(更好的购物车-@ilyaWD)。