Circleci — один из CI, который может помочь в построении теста на нем. У Circleci есть очень хорошая документация по пониманию и реализации теста с отличной документацией.
Мы можем легко интегрировать тест с нижеприведенными репозиториями. Конфигурации можно добавить по пути .circleci/config.yml
в корне.
Я добавил в проект приведенный ниже файл config.yml. В проекте есть образ докера для хрома и фаерфокса. Добавлена установка для запуска и сборки всех библиотек с помощью npm ci
. Добавлена команда для запуска теста для доступного теста в проекте npm run run-test-yarn
.
version: 2.1 orbs: circleci-cli: circleci/[email protected] jobs: build: docker: - image: cypress/browsers:node18.6.0-chrome105-ff104 working_directory: ~/repo steps: - checkout # Download and cache dependencies - restore_cache: keys: - v1-dependencies-{{ checksum "package.json" }} # fallback to using the latest cache if no exact match is found - v1-dependencies- - run: npm ci - run: npm run run-test-yarn
Как только мы войдем в Circleci, он попросит пройти аутентификацию и дать разрешение на доступ к хранилищу. После авторизации репозитория мы можем увидеть проект, доступный в репозитории. В репозитории я использую Gitlab и настроил один из доступных репозиториев с помощью Circleci. Поскольку Circle CI не является встроенным репозиторием, на экране конвейера он будет отображаться как Внешний репозиторий.
Как только Circleci войдет в систему, мы увидим панель инструментов и список проектов, связанных с учетной записью.
Мы видим панель инструментов и список конвейеров, связанных с адресом электронной почты. Имеет статус пайплайна с названием ветки и продолжительностью.
Основываясь на списке шагов, которые мы добавили в конфиг, мы можем видеть это как шаги по выполнению CI.
Логи выполнения ниже для выполненных тестов. Мы также можем добавить артефакты, когда есть файл или отчет для выполнения теста.
> run-test-yarn > npx cypress run --env allure=true --browser chrome [701:1111/143247.636036:ERROR:gpu_init.cc(453)] Passthrough is not supported, GL is swiftshader, ANGLE is ==================================================================================================== (Run Starting) ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Cypress: 9.6.1 │ │ Browser: Chrome 105 (headless) │ │ Node Version: v18.6.0 (/usr/local/bin/node) │ │ Specs: 2 found (DataDriven.feature, Search.feature) │ └────────────────────────────────────────────────────────────────────────────────────────────────┘ ──────────────────────────────────────────────────────────────────────────────────────────────────── Running: DataDriven.feature (1 of 2) Data Driven Test for multiple cases ✓ Read data to a json file (56ms) ✓ Write data to a json file (24ms) ✓ Read data from a txt file (23ms) ✓ Write data from a txt file (17ms) ✓ Read excel file (50ms) ✓ write excel file (21ms) 6 passing (233ms) (Results) ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Tests: 6 │ │ Passing: 6 │ │ Failing: 0 │ │ Pending: 0 │ │ Skipped: 0 │ │ Screenshots: 0 │ │ Video: false │ │ Duration: 0 seconds │ │ Spec Ran: DataDriven.feature │ └────────────────────────────────────────────────────────────────────────────────────────────────┘ ──────────────────────────────────────────────────────────────────────────────────────────────────── Running: Search.feature (2 of 2) Test feature for search 1) Search scenario for the list of search. (example #1) 2) Search scenario for the list of search -fail test case. (example #1) 0 passing (13s) 2 failing 1) Test feature for search Search scenario for the list of search. (example #1): AssertionError: Timed out retrying after 4000ms: Expected to find element: `[alt='Google']`, but never found it. at Context.eval (https://www.google.com/__cypress/tests?p=cypress/integration/Search.feature:93:28) at Context.resolveAndRunStepDefinition (https://www.google.com/__cypress/tests?p=cypress/integration/Search.feature:7041:29) at Context.eval (https://www.google.com/__cypress/tests?p=cypress/integration/Search.feature:6362:35) 2) Test feature for search Search scenario for the list of search -fail test case. (example #1): AssertionError: Timed out retrying after 4000ms: Expected to find element: `[alt='Google']`, but never found it. at Context.eval (https://www.google.com/__cypress/tests?p=cypress/integration/Search.feature:93:28) at Context.resolveAndRunStepDefinition (https://www.google.com/__cypress/tests?p=cypress/integration/Search.feature:7041:29) at Context.eval (https://www.google.com/__cypress/tests?p=cypress/integration/Search.feature:6362:35) (Results) ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Tests: 2 │ │ Passing: 0 │ │ Failing: 2 │ │ Pending: 0 │ │ Skipped: 0 │ │ Screenshots: 2 │ │ Video: false │ │ Duration: 13 seconds │ │ Spec Ran: Search.feature │ └────────────────────────────────────────────────────────────────────────────────────────────────┘ (Screenshots) - /root/repo/cypress/screenshots/Search.feature/Test feature for search -- Search (1280x720) scenario for the list of search. (example #1) (failed).png - /root/repo/cypress/screenshots/Search.feature/Test feature for search -- Search (1280x720) scenario for the list of search -fail test case. (example #1) (failed).png ==================================================================================================== (Run Finished) Spec Tests Passing Failing Pending Skipped ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │ ✔ DataDriven.feature 232ms 6 6 - - - │ ├────────────────────────────────────────────────────────────────────────────────────────────────┤ │ ✖ Search.feature 00:13 2 - 2 - - │ └────────────────────────────────────────────────────────────────────────────────────────────────┘ ✖ 1 of 2 failed (50%) 00:13 8 6 2 - - Exited with code exit status 2
Конфигурацию Circleci можно найти в документации.
Заключение
Попробовать Circleci очень просто, и они дают бесплатные кредиты, чтобы попробовать наши собственные проекты. Circleci дает 30000 кредитов в месяц. У них очень хорошая поддержка документации.
Я создал проект на GitLab и добавил код здесь.
Не стесняйтесь хлопать в ладоши, если вам нравится контент. Удачного тестирования автоматизации :) Ура. 👏