feat: add openim test docs

pull/2159/head
Xinwei Xiong (cubxxw) 2 years ago
parent 00a90003be
commit 22d650cadb

@ -1,4 +1,4 @@
#fixme Clone openIM Server project before using docker-compose,project addresshttps://github.com/OpenIMSDK/Open-IM-Server.git #fixme Clone openIM Server project before using docker-compose,project addresshttps://github.com/openimsdk/open-im-server.git
# The command that triggers this file to pull the image is "docker compose up -f" # The command that triggers this file to pull the image is "docker compose up -f"
version: '3' version: '3'

@ -1,4 +1,4 @@
#fixme Clone openIM Server project before using docker-compose,project addresshttps://github.com/OpenIMSDK/Open-IM-Server.git #fixme Clone openIM Server project before using docker-compose,project addresshttps://github.com/openimsdk/open-im-server.git
# The command that triggers this file to pull the image is "docker compose up -d". # The command that triggers this file to pull the image is "docker compose up -d".
version: '3' version: '3'

@ -2,7 +2,7 @@
## Script Logging Documentation Link ## Script Logging Documentation Link
If you wish to view the script's logging documentation, you can click on this link: [Logging Documentation](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/contrib/bash-log.md). If you wish to view the script's logging documentation, you can click on this link: [Logging Documentation](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/bash-log.md).
Below is the documentation for logging and error handling in the OpenIM Go project. Below is the documentation for logging and error handling in the OpenIM Go project.

@ -2,14 +2,94 @@
This document serves as a comprehensive guide to understanding and utilizing the `test.sh` script for testing OpenIM RPC services. The `test.sh` script is a collection of bash functions designed to test various aspects of the OpenIM RPC services, ensuring that each part of the API is functioning as expected. This document serves as a comprehensive guide to understanding and utilizing the `test.sh` script for testing OpenIM RPC services. The `test.sh` script is a collection of bash functions designed to test various aspects of the OpenIM RPC services, ensuring that each part of the API is functioning as expected.
+ Scriptshttps://github.com/OpenIMSDK/Open-IM-Server/tree/main/scripts/install/test.sh + Scriptshttps://github.com/openimsdk/open-im-server/tree/main/scripts/install/test.sh
For some complex, bulky functional tests, performance tests, and various e2e tests, We are all in the current warehouse to https://github.com/OpenIMSDK/Open-IM-Server/tree/main/test or https://github.com/openim-sigs/test-infra directory In the. For some complex, bulky functional tests, performance tests, and various e2e tests, We are all in the current warehouse to https://github.com/openimsdk/open-im-server/tree/main/test or https://github.com/openim-sigs/test-infra directory In the.
+ About OpenIM Feature [Test Docs](https://docs.google.com/spreadsheets/d/1zELWkwxgOOZ7u5pmYCqqaFnvZy2SVajv/edit?usp=sharing&ouid=103266350914914783293&rtpof=true&sd=true) + About OpenIM Feature [Test Docs](https://docs.google.com/spreadsheets/d/1zELWkwxgOOZ7u5pmYCqqaFnvZy2SVajv/edit?usp=sharing&ouid=103266350914914783293&rtpof=true&sd=true)
## Util Test
## Usage Let's restructure and enhance the document under a unified second-level heading, adding clarity and details for better comprehension and visual appeal.
---
## Development Guide
### Comprehensive Testing Instructions
#### Running Unit Tests
- **Command**: To execute unit tests, input the following in your terminal:
```
make test
```
#### Evaluating Test Coverage
- **Overview**: It's crucial to assess how much of your code is covered by tests.
- **Command**:
```bash
make cover
```
This command generates a report detailing the percentage of your code tested, ensuring adherence to quality standards.
#### Conducting API Tests
- **Purpose**: API tests validate the interaction and functionality of your application's interfaces.
- **How to Run**:
```
make test-api
```
Use this to check the integrity and reliability of your API endpoints.
#### End-to-End (E2E) Testing
- **Scope**: E2E tests simulate real-user scenarios from start to finish.
- **Execution**:
```
make test-e2e
```
This comprehensive testing ensures your application performs as expected in real-world situations.
### Crafting Unit Test Cases
#### Setup for Test Case Generation
- **Installation**: Install the `gotests` tool to generate test cases automatically.
```bash
make install.gotests
```
This command installs the `gotests` tool for test case generation.
- **Environment Preparation**: Define your test template environment variable and generate test cases as shown below:
```bash
export GOTESTS_TEMPLATE=testify
gotests -i -w -only keyFunc .
```
This prepares your environment for test case generation using the `testify` template.
#### Isolating Function Tests
- **Single Function Testing**: When you need to focus on testing a single function for detailed examination.
- **Method**:
```bash
go test -v -run TestKeyFunc
```
This command specifically runs tests for `TestKeyFunc`, allowing targeted debugging and validation.
### Important Note
- **Quality Assurance**: Throughout your development process, it is imperative to ensure that the unit test coverage meets or surpasses the standards set by OpenIM.
- **Maintaining Standards**: Regularly running your tests with
```make test```
supports maintaining high code quality and adherence to OpenIM's rigorous testing benchmarks.
## E2E Test
TODO
## Api Test
The `test.sh` script is located within the `./scripts/install/` directory of the OpenIM service's codebase. To use the script, navigate to this directory from your terminal: The `test.sh` script is located within the `./scripts/install/` directory of the OpenIM service's codebase. To use the script, navigate to this directory from your terminal:

@ -37,8 +37,6 @@ DELVE_VERSION ?= latest
AIR_VERSION ?= latest AIR_VERSION ?= latest
GOLINES_VERSION ?= latest GOLINES_VERSION ?= latest
GO_MOD_OUTDATED_VERSION ?= latest GO_MOD_OUTDATED_VERSION ?= latest
MOCKGEN_VERSION ?= latest
PROTOC_GEN_GO_VERSION ?= latest
CFSSL_VERSION ?= latest CFSSL_VERSION ?= latest
DEPTH_VERSION ?= latest DEPTH_VERSION ?= latest
GO_CALLVIS_VERSION ?= latest GO_CALLVIS_VERSION ?= latest
@ -48,4 +46,11 @@ RICHGO_VERSION ?= latest
RTS_VERSION ?= latest RTS_VERSION ?= latest
TYPECHECK_VERSION ?= latest TYPECHECK_VERSION ?= latest
COMMENT_LANG_DETECTOR_VERSION ?= latest COMMENT_LANG_DETECTOR_VERSION ?= latest
STANDARDIZER_VERSION ?= latest STANDARDIZER_VERSION ?= latest
GO_TESTS_VERSION ?= v1.6.0
GO_APIDIFF_VERSION ?= v0.8.2
WIRE_VERSION ?= latest
# WIRE_VERSION ?= $(call get_go_version,github.com/google/wire)
MOCKGEN_VERSION ?= $(call get_go_version,github.com/golang/mock)
PROTOC_GEN_GO_VERSION ?= $(call get_go_version,github.com/golang/protobuf/protoc-gen-go)

@ -102,6 +102,15 @@ install.go-junit-report:
@$(GO) install github.com/jstemmer/go-junit-report@$(GO_JUNIT_REPORT_VERSION) @$(GO) install github.com/jstemmer/go-junit-report@$(GO_JUNIT_REPORT_VERSION)
## install.gotests: Install gotests, used to generate go tests ## install.gotests: Install gotests, used to generate go tests
install.gotests:
@$(GO) install github.com/cweill/gotests/gotests@$(GO_TESTS_VERSION)
## install.go-apidiff: Install go-apidiff, used to check api changes
.PHONY: install.go-apidiff
install.go-apidiff:
@$(GO) install github.com/joelanford/go-apidiff@$(GO_APIDIFF_VERSION)
## install.swagger: Install swagger, used to generate swagger documentation
.PHONY: install.swagger .PHONY: install.swagger
install.swagger: install.swagger:
@$(GO) install github.com/go-swagger/go-swagger/cmd/swagger@$(SWAGGER_VERSION) @$(GO) install github.com/go-swagger/go-swagger/cmd/swagger@$(SWAGGER_VERSION)
@ -191,6 +200,12 @@ install.go-mod-outdated:
install.mockgen: install.mockgen:
@$(GO) install github.com/golang/mock/mockgen@$(MOCKGEN_VERSION) @$(GO) install github.com/golang/mock/mockgen@$(MOCKGEN_VERSION)
## install.wire: Install wire, used to generate wire files
.PHONY: install.wire
install.wire:
@$(GO) install github.com/google/wire/cmd/wire@$(WIRE_VERSION)
## install.protoc-gen-go: Install protoc-gen-go, used to generate go source files from protobuf files ## install.protoc-gen-go: Install protoc-gen-go, used to generate go source files from protobuf files
.PHONY: install.protoc-gen-go .PHONY: install.protoc-gen-go
install.protoc-gen-go: install.protoc-gen-go:

Loading…
Cancel
Save