プロジェクトは、受け入れテストを実行するためにリリースされました

みなさん、こんにちは。今日は朗報です。Webサービスの受け入れテストを管理および実行するプロジェクトであるat2kのベータ版がリリースされました。主な機能を見てみましょうこちらでも確認できます



前書き



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"} –


, -



  1. ,




, . 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


http://56dd9be41097.ngrok.io



, , , . , 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)。




All Articles