grpcio_testing code samples

278 views
Skip to first unread message

M T

unread,
Nov 16, 2021, 9:32:13 AM11/16/21
to grpc.io
Hi all,

I'm just starting to get into grpc, and was wondering about tests. The documentation of the testing package only lists what classes etc. are available, but not really how to use them - would it be possible to add small testing examples to the general code examples, to help people starting out?

yas...@google.com

unread,
Dec 1, 2021, 2:10:47 PM12/1/21
to grpc.io
Thank you for the feedback! Do the examples in https://github.com/grpc/grpc/tree/master/examples and https://github.com/grpc/grpc/tree/master/test help?

M T

unread,
Dec 4, 2021, 3:53:56 PM12/4/21
to yas...@google.com, grpc.io
One thing I just noticed that I didn't include in my original request: I'm looking for examples on how to write tests for python grpc services & clients.

Thanks for getting back to me - but unfortunately, neither link helps:

https://github.com/grpc/grpc/tree/master/examples only contains usage examples of actually implementing services / clients, but not about  how to test them
https://github.com/grpc/grpc/tree/master/test only contains a bunch of .cc files, which don't help in my case, since I'm looking for python unit tests, and the only python-related files I could find in there where about testing the generation of the wheels that are required for the python grpcio packages

When I said "the documentation only lists what classes / methods exist, but not how to use them", I was talking about this: https://grpc.github.io/grpc/python/grpc_testing.html - and this is quite cryptic to a newbie like me. A simple example (e.g. unit tests for the hello world example) would be enough to get started, but the way it is, I can't really make sense of any of these classes. And googling also didn't provide me with any kind of guidance on the python grpc test classes..... A possible place to add such an example would be https://grpc.io/docs/languages/python/basics/, I guess, which contains the hello world example for python.

--
You received this message because you are subscribed to a topic in the Google Groups "grpc.io" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grpc-io/pNIulgyXSQ0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/a787b200-e683-4a48-9d90-f1da02430f41n%40googlegroups.com.

Lidi Zheng

unread,
Jan 24, 2022, 12:28:38 PM1/24/22
to grpc.io
The grpc-testing package is for mocking the services. It can intercept messages, inject logic, alter timestamp.

How to write tests is a programming philosophy question. In most of the gRPC Python tests, we try to use "end2end" style tests, conduct tests only using the public API.
Reply all
Reply to author
Forward
0 new messages