This documentation provides a step-by-step guide for running tests within the gitlab-org/gitlab-ce
project. This guide is designed for expert developers who are familiar with the overall structure and functionality of the project.
Prerequisites
Before running the tests, ensure that you have the following prerequisites:
Ruby: The project is built on Ruby, so ensure you have a compatible version installed.
Rails: The project requires Rails framework. Install it via:
gem install rails
Node.js and Yarn: Frontend tests require Node.js and Yarn. Install them if not already available.
Database: Ensure you have PostgreSQL or the database configured for your setup.
Setting Up the Environment
Clone the Repository: First, clone the repository using the following command:
git clone https://gitlab.com/gitlab-org/gitlab-ce.git cd gitlab-ce
Install Dependencies: Run the following command to install the necessary gems:
bundle install
Set Up the Database: Create and migrate the database:
bundle exec rake db:create db:migrate
Seed the Database (optional): This step is usually performed to populate the database with initial data:
bundle exec rake db:seed
Running Tests
1. Running Rails Tests
To run the Rails tests, execute the following command:
bundle exec rspec
This will run the complete suite of Ruby tests using RSpec. For more targeted testing (e.g., only model specs), you can specify the directory:
bundle exec rspec spec/models
2. Running Frontend Tests
For running frontend tests, you should first install the JavaScript dependencies:
yarn install
To execute the frontend tests, run:
yarn test
You can also run tests related to specific directories. For example:
yarn test frontend/spec
3. Running System Tests
To run system tests that require a running instance of the application, start the test server:
rails server
Then execute system tests using RSpec:
bundle exec rspec spec/system
Additional Testing Options
You can run tests with specific options to tailor the output. For example, to run tests with a specific seed:
bundle exec rspec --seed 1234
Code Coverage
To generate code coverage reports, you may use SimpleCov by adding it to your Gemfile and then executing tests as follows:
RACK_ENV=test bundle exec rspec
Conclusion
Running tests in gitlab-org/gitlab-ce
is a structured process that involves setting up your environment, executing Rails tests, frontend tests, and system tests. Ensure all dependencies are installed and configured properly to facilitate a smooth testing experience.
Source: [gitlab-org/gitlab-ce documentation]