AgentSkillsCN

test

运行connectrpc-axum的完整测试套件。当用户要求运行测试、验证更改或检查代码是否正常工作时使用。

SKILL.md
--- frontmatter
name: test
description: Run the complete test suite for connectrpc-axum. Use when the user asks to run tests, verify changes, or check if the code works.

test

Run the complete test suite for connectrpc-axum using cargo-make.

Quick Start

bash
# Run all tests (unit + Rust client + Go client)
cargo make test

This runs the integration test runner which:

  • Allocates unique ports dynamically for each test (prevents port conflicts)
  • Runs unit tests, Rust client tests, and Go client tests
  • Provides colored output with pass/fail status
  • Ensures proper cleanup of server processes

Cargo Make Commands

CommandDescription
cargo make testRun all tests
cargo make test-unitRun unit tests only
cargo make test-rust-clientRun Rust client integration tests (against Rust servers)
cargo make test-go-clientRun Go client integration tests (against Rust servers)
cargo make test-cross-implRun cross-implementation tests (Rust clients against Go server)
cargo make test-verboseRun all tests with verbose output
cargo make test-filter <pattern>Run tests matching a filter

Examples

bash
# Run all tests (unit + Rust client + Go client + cross-impl)
cargo make test

# Run only unit tests (fastest)
cargo make test-unit

# Run only Rust client tests (against Rust servers)
cargo make test-rust-client

# Run only Go client tests (against Rust servers)
cargo make test-go-client

# Run only cross-implementation tests (Rust clients against Go server)
cargo make test-cross-impl

# Run with verbose output
cargo make test-verbose

# Filter tests by name
cargo make test-filter TestConnectUnary
cargo make test-filter "Unary"

CI Commands

bash
# Full CI: fmt-check + clippy + all tests
cargo make ci

# Quick CI: fmt-check + clippy + unit tests only
cargo make ci-quick

Direct Integration Test Runner (Alternative)

If cargo-make is not installed, run the integration test binary directly:

bash
# Run all tests
cargo run -p connectrpc-axum-examples --bin integration-test

# Run only unit tests
cargo run -p connectrpc-axum-examples --bin integration-test -- --unit

# Run only Rust client tests
cargo run -p connectrpc-axum-examples --bin integration-test -- --rust-client

# Run only Go client tests
cargo run -p connectrpc-axum-examples --bin integration-test -- --go-client

# Filter tests by name
cargo run -p connectrpc-axum-examples --bin integration-test -- --filter TestConnectUnary

# Verbose output
cargo run -p connectrpc-axum-examples --bin integration-test -- -v

Success Criteria

The test runner shows a summary:

code
=== Summary ===

Passed: X
Failed: 0
Total: X

All tests should pass (Failed: 0).

Test Categories

Unit Tests

  • All crate unit tests and doc tests via cargo test --workspace

Rust Client Tests (against Rust servers)

TestServerDescription
unary-clientconnect-unaryUnary calls (JSON + Proto encoding)
server-stream-clientconnect-server-streamServer streaming
client-stream-clientconnect-client-streamClient streaming
bidi-stream-clientconnect-bidi-streamBidirectional streaming

Go Client Tests (against Rust servers)

TestServerProtocol
TestConnectUnaryconnect-unaryConnect
TestConnectServerStreamconnect-server-streamConnect
TestTonicUnary*tonic-unaryConnect + gRPC
TestTonicServerStream*tonic-server-streamConnect + gRPC
TestTonicBidiStream*tonic-bidi-streamConnect + gRPC
TestGRPCWebgrpc-webgRPC-Web
TestProtocolVersionprotocol-versionConnect
TestTimeouttimeoutConnect
TestExtractor*extractor-*Connect
TestStreamingErrorHandlingstreaming-error-reproConnect

Cross-Implementation Tests (Rust clients against Go server)

Rust ClientDescription
unary-clientUnary calls (JSON + Proto encoding)
server-stream-clientServer streaming
client-stream-clientClient streaming
bidi-stream-clientBidirectional streaming
typed-clientTyped client API

The Go server is located in connectrpc-axum-examples/go-server/ and implements all proto services (HelloWorldService, EchoService) using connect-go.

Failure Handling

Test runner failures: Check the failed test name and output shown below it.

Port issues: The integration test runner uses dynamic ports, so port conflicts should not occur.

Build errors: Run cargo make build-examples or cargo build -p connectrpc-axum-examples --features tonic first.

Go dependency issues: Run go mod tidy in connectrpc-axum-examples/go-client/.

cargo-make not installed: Install with cargo install cargo-make or use the direct integration test runner commands above.

Environment Variables

VariableDescriptionDefault
PORTServer listen port3000
SERVER_URLClient target URLhttp://localhost:3000