This section provides a step-by-step guide for running tests in the open-telemetry/opentelemetry-demo project, which encompasses multiple languages and their respective testing frameworks.
Prerequisites
Ensure you have the following installed on your system:
- Go
- Node.js
- Python
- Java
- Docker
- Relevant language-specific tools for testing (Maven for Java, pytest for Python, etc.)
Running Tests
Go
Navigate to the Checkout Service Directory
Change to the project directory that contains the Go code:cd src/checkoutservice
Run the Tests
Use the go test command to execute the tests in the package:go test -v
This will provide verbose output of the test results.
Java
Navigate to the Java Directory
Change to the Java project directory:cd src/java
Run the Tests Using Maven
Execute the following command to run all tests:mvn test
This command will compile the code and execute the tests defined in your Java project.
Python
Navigate to the Python Directory
Move to the directory containing the Python code:cd src/python
Run the Tests Using pytest
Execute the command below to run the tests:pytest -v
The
-v
option stands for verbose, providing detailed output for the tests being run.
JavaScript
Navigate to the JavaScript Directory
Change to the JavaScript project directory:cd src/javascript
Run the Tests Using npm or yarn
Depending on your package manager, run:For npm:
npm test
For yarn:
yarn test
C#
Navigate to the C# Directory
Change to the C# project directory:cd src/csharp
Run the Tests Using dotnet
Execute the following command:dotnet test
Other Languages
Follow similar steps for the remaining languages in the project (e.g., PHP, Rust, Ruby). Locate the directory associated with each language and utilize their specific testing tools:
PHP: Navigate to the PHP directory and run
phpunit
.Rust: Navigate to the Rust directory and run
cargo test
.Ruby: Navigate to the Ruby directory and run
rspec
.
Each of these commands will execute the implemented tests and provide feedback on their success or failure.
Using Makefile for Running Tests
A unified approach to running tests across all languages is available through the Makefile provided in the project.
Invoke the Makefile
In the root directory of the project, execute:make test
This command will trigger the default target defined in the Makefile that orchestrates the calls to each languageās testing mechanism.
Conclusion
This guide outlines the steps necessary to run tests for the open-telemetry/opentelemetry-demo project across multiple languages. By following these instructions, developers can verify the integrity and functionality of the various components of the project.
Source: Makefile