Skip to content

Testing Patterns

gRPC Testify uses a universal .gctf format that works with all gRPC communication patterns. The same testing principles apply regardless of whether you're testing unary, streaming, or bidirectional services.

Universal Testing Principles

The .gctf format handles all gRPC patterns consistently across different types:

  • Request-Response Validation - Verify correct data exchange
  • Error Handling - Test both success and failure scenarios
  • Performance Monitoring - Ensure acceptable response times
  • Security Validation - Test authentication and authorization
  • Data Integrity - Validate response structure and content

Core Testing Categories

🔍 Data Validation

Learn how to validate response data, test different data types, and handle complex nested structures.

Error Testing

Master testing error conditions, validation failures, and expected error scenarios.

🔐 Security Testing

Test authentication, authorization, TLS certificates, and secure endpoints.

Performance Testing

Validate response times, test under load, and optimize test execution.

🎯 Assertion Patterns

Master universal assertion techniques for all gRPC types and data structures.

gRPC Type-Specific Considerations

Unary RPC

  • One request → One response
  • Use RESPONSE OR ASSERTS (not both)
  • Simple validation patterns

Server Streaming

  • One request → Multiple responses
  • Use multiple ASSERTS sections
  • Validate each response in sequence

Client Streaming

  • Multiple requests → One response
  • Use multiple REQUEST sections
  • Validate final response

Bidirectional Streaming

  • Multiple requests ↔ Multiple responses
  • Use multiple REQUEST and ASSERTS sections
  • Complex validation patterns

Quick Reference

Basic Test Structure

php
--- ADDRESS ---
localhost:4770

--- ENDPOINT ---
service.ServiceName/MethodName

--- REQUEST ---
{ "input": "test_data" }

--- RESPONSE ---
{
  "result": "expected_response",
  "status": "success"
}

Common OPTIONS

php
--- OPTIONS ---
timeout: 30          # Test timeout in seconds
timeout: 30  # Test timeout in seconds
retry: 3             # Number of retry attempts

Next Steps

Explore the detailed guides above to master each testing category:

Ready to test your gRPC services? Start with Data Validation or explore Real Examples!

Released under the MIT License.