Prueba de unidades de Cloud Pub/Sub (2ª gen.)
bookmark_borderbookmark
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Ejemplo de prueba de unidades para una función activada por Cloud Pub/Sub que se ejecuta en Cloud Functions (2nd gen).
Muestra de código
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","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."]]],[]]