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 cliPrepare 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-unitThis 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 lintAddress 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 testThis 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-coverageThis 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 cleanThis 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 shellThis 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 mddocsThis 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.