To run tests for the project, follow these detailed steps:
Clone the Repository
First, ensure you have the Docker CLI repository cloned onto your local machine:
git clone https://github.com/docker/cli.git cd cli
Prepare the Environment
Ensure Docker is running and that you are in the project root directory.
Run Unit Tests
The Makefile provides a function specifically for running unit tests. Execute the following command:
make test-unit
This command will trigger the necessary unit tests defined within the project.
Check for Code Linting Issues (Optional but Recommended)
You can verify the code quality by running the linting checks before or after executing tests. This can be done with:
make lint
Address any issues reported by the linting process to ensure your code adheres to best practices.
Run All Tests
To run all tests, including unit tests and any other test suites defined in the Makefile, utilize:
make test
This function is a catch-all for executing different types of tests, allowing thorough testing of the project.
Generate Test Coverage Reports (Optional)
For detailed feedback on test coverage, you can run the following command:
make test-coverage
This will generate a coverage report, helping you identify sections of the codebase that may lack sufficient testing.
Cleaning Up After Tests
After tests have been executed, especially in a CI/CD pipeline, running a clean-up process can be beneficial. This can be done with:
make clean
This step ensures that unnecessary files are removed, keeping your workspace tidy.
Run Shell Tests (If Applicable)
If your project includes shell scripts that require testing, execute:
make shell
This step will run any shell-related tests available within the project scope.
Generate Documentation (Optional)
You may want to create documentation from the test results or project state. You can generate markdown documentation with:
make mddocs
This will help document the current state of your tests or project.
Check Help for More Options
When in doubt or seeking further options regarding commands available in the Makefile, you can type:
make help
This command will display a list of all available Makefile functions along with a brief description of each.
By following these steps, you can efficiently run and manage tests within the project.
Sources:
- Makefile available in the Docker CLI repository.