# Testing standards and style guidelines

> 原文：[https://docs.gitlab.com/ee/development/testing_guide/](https://docs.gitlab.com/ee/development/testing_guide/)

*   [Overview](#overview)
*   [Testing levels](#testing-levels)
*   [Testing best practices](#testing-best-practices)
*   [Frontend testing standards and style guidelines](#frontend-testing-standards-and-style-guidelines)
*   [Flaky tests](#flaky-tests)
*   [GitLab tests in the Continuous Integration (CI) context](#gitlab-tests-in-the-continuous-integration-ci-context)
*   [Review apps](#review-apps)
*   [Testing Rake tasks](#testing-rake-tasks)
*   [End-to-end tests](#end-to-end-tests)
*   [Migrations tests](#migrations-tests)

# Testing standards and style guidelines[](#testing-standards-and-style-guidelines "Permalink")

本文档介绍了自动测试 GitLab 项目的各种指南和最佳实践.

它是对[Thoughtbot 测试风格指南](https://github.com/thoughtbot/guides/tree/master/style/testing)的*扩展* . 如果本指南定义的规则与 Thoughtbot 指南相抵触，则以本指南为准. 可能会逐字重复某些准则以强调其重要性.

## Overview[](#overview "Permalink")

GitLab 建立在[Ruby on Rails](https://rubyonrails.org/)之上，并且我们将[RSpec](https://github.com/rspec/rspec-rails#feature-specs)用于所有后端测试，而[Capybara](https://github.com/teamcapybara/capybara)用于端到端集成测试. 在前端，我们将[Jest](https://jestjs.io/)和[Karma](http://karma-runner.github.io/) / [Jasmine](https://jasmine.github.io/)用于 JavaScript 单元和集成测试.

以下是两篇很棒的文章，每个人都应该阅读它们，以了解自动化测试的含义以及其原理是什么：

*   [五因素测试](https://madeintandem.com/blog/five-factor-testing/) ：为什么我们需要测试？
*   [自动化测试的原则：测试](https://www.lihaoyi.com/post/PrinciplesofAutomatedTesting.html)级别. 确定测试的优先级. 测试费用.

## [Testing levels](testing_levels.html)[](#testing-levels "Permalink")

Learn about the different testing levels, and how to decide at what level your changes should be tested.

## [Testing best practices](best_practices.html)[](#testing-best-practices "Permalink")

关于编写良好测试的所有知识，包括：测试设计，RSpec，FactoryBot，系统测试，参数化测试等.

## [Frontend testing standards and style guidelines](frontend_testing.html)[](#frontend-testing-standards-and-style-guidelines "Permalink")

您应该知道的有关如何编写良好的前端测试的所有知识：业力，测试承诺，存根等.

## [Flaky tests](flaky_tests.html)[](#flaky-tests "Permalink")

什么是片状测试，我们遇到的不同类型的片状测试，以及我们如何处理它们.

## [GitLab tests in the Continuous Integration (CI) context](ci.html)[](#gitlab-tests-in-the-continuous-integration-ci-context "Permalink")

GitLab 测试套件如何在 CI 上下文中运行：设置，缓存，工件，并行化，监视.

## [Review apps](review_apps.html)[](#review-apps "Permalink")

如何为 GitLab CE / EE 设置评论应用程序以及如何使用它们.

## [Testing Rake tasks](testing_rake_tasks.html)[](#testing-rake-tasks "Permalink")

您应该了解的有关如何测试 Rake 任务的所有知识.

## [End-to-end tests](end_to_end/index.html)[](#end-to-end-tests "Permalink")

您应该了解有关如何使用[GitLab QA](https://gitlab.com/gitlab-org/gitlab-qa)测试框架进行端到端测试的所有知识.

## [Migrations tests](testing_migrations_guide.html)[](#migrations-tests "Permalink")

您应该了解的有关如何测试迁移的一切.

[Return to Development documentation](../README.html)