Tests unitaires Cloud Pub/Sub (2e génération)
bookmark_borderbookmark
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Exemple de test unitaire pour une fonction déclenchée par Cloud Pub/Sub qui s'exécute dans Cloud Functions (2e génération).
Exemple de code
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],[],[[["This webpage provides unit test examples for Cloud Pub/Sub-triggered functions running on Cloud Functions (2nd Gen) in C#, Go, and PHP."],["The C# code demonstrates testing a function that processes messages with and without text data, using `Xunit` for assertions and a `MemoryLogger` for logging checks."],["The Go example showcases testing `helloPubSub` function with varying input data, by capturing the log output, and it utilizes the `cloudevents` library to simulate CloudEvents."],["The PHP unit tests use `PHPUnit` to test the `helloworldPubsub` function by simulating a CloudEvent and asserting that the function's output contains the expected greeting, handling output capture by overriding the function's logging."],["Setting up Application Default Credentials is required for authenticating to Cloud Run functions during local development, and a link is provided for more details on the process."]]],[]]