The project was released to run acceptance tests

Hello everyone, today I have good news: a beta version of at2k , a project for managing and running acceptance tests for web services, is out. Let's take a look at its main features, which you can also check here .



Introduction



AT2K is an open source project written in Golang (for the backend language) and Angular (for the client side). The main idea and goal is to allow users (programmers, QA engineers, and possibly managers) to write and run tests in a language close to their subject area.



A couple of examples



Before we start looking at the UI and the various options for customizing tests, let me show you an example of a service that is supposed to be tested and directly tested.



So, the service implementation (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}`);
});


Without further ado, here are a couple of tests:



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


As you can see, everything is pretty simple.



Where to begin



To get started, we need to create an account by following the link and entering the username and password that we want to use.



.



, ,

- ( ):



image



, ,

, :



BEGIN
  createUserResponse = CREATE USER {"name": "Joe"}
END




  • createUserResponse – ,

  • CREATE –
  • USER – ,
  • {"name": "Joe"} –


, -



  1. ,




, . Create object :



image



. USER.



, Create, :



image



, 2 – GET CREATE. GET. (. ) :



image



Add command , :



image



Create ( , .. ).



CREATE:



image



, :



image



image



.



-



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



image



Update .





, 1 – . (, get_create_tests.txt) . , Run tests, Tests file , . Run tests , , :



image



, .



?



, , (USER), , .





Any suggestions for improving the project are appreciated - I'm here to get feedback.



If someone decides to study the code in the repository and suggest improvements or comments, I will also be happy (better in the cart - @ilyaWD).




All Articles