To effectively run tests for the project, follow these detailed steps. This process utilizes the provided Makefile, which contains several built-in functions to facilitate your testing needs.

Preliminary Steps

Ensure you have Docker and Docker Compose installed and running on your system, as these are prerequisites for managing the project environment.

Build the Project

Before running the tests, you must build the project. You will utilize the build function from the Makefile.

make build

This command compiles the Go code located in the project and prepares it for testing.

Running Unit Tests

Run the unit tests using the test function from the Makefile. This function will execute all unit tests included in the Go code.

make test

Execute this command in the root of your project directory where the Makefile is located. The output will display the results of the tests.

Running End-to-End Tests

To run End-to-End (E2E) tests, the project provides dedicated functions in the Makefile. Depending on your requirements, you may choose between running E2E tests with or without a standalone Compose setup.

First, you may want to run the standard E2E tests:

make e2e

If your project setup requires a standalone configuration, use the following command to run the E2E tests with a standalone Compose setup:

make e2e-compose-standalone

Code Coverage

For obtaining code coverage during testing, you can use the binary-with-coverage functionality provided in the Makefile. This will create a binary with code coverage included.

make binary-with-coverage

After execution, you can analyze the coverage report generated in the output directory specified in your project settings.

Validate Documentation and Go Modules

As you run tests, it is also beneficial to ensure that documentation and Go Modules are validated. This can maintain the quality and integrity of your project alongside tests.

To validate documentation, use:

make validate-docs

For validating Go Modules:

make validate-go-mod

Mocks and Dependencies

If your tests rely on mocks or specific dependencies, you can generate or check mocks using:

make mocks

For checking dependencies, utilize:

make check-dependencies

Conclusion

By following these steps and utilizing the provided Makefile functions, expert developers can execute tests efficiently in the project’s Dockerized environment. Always ensure that you address any issues highlighted during testing and validation phases, maintaining the robustness of your codebase.