আপনার ফাংশনের প্রতিটি এক্সিকিউশনে একটি TestMatrix পাস করা হয় যাতে ম্যাট্রিক্সের চূড়ান্ত অবস্থা এবং সমস্যাগুলি বুঝতে সাহায্য করার জন্য বিশদ অন্তর্ভুক্ত থাকে।
পরীক্ষার ম্যাট্রিক্স বিভিন্ন উত্স বা কর্মপ্রবাহ থেকে তৈরি করা যেতে পারে। তাই প্রায়শই এমন ফাংশন তৈরি করা বাঞ্ছনীয় যা উত্স বা পরীক্ষার অন্যান্য গুরুত্বপূর্ণ প্রসঙ্গের উপর ভিত্তি করে বিভিন্ন ক্রিয়া সম্পাদন করে। এটিতে সাহায্য করার জন্য, gcloud আপনাকে একটি পরীক্ষা শুরু করার সময় নির্বিচারে তথ্য পাস করার অনুমতি দেয় যা আপনার ফাংশনে পরে অ্যাক্সেস করা যেতে পারে। যেমন:
gcloud beta firebase test android run \
--app=path/to/app.apk \
--client-details testType=pr,link=https://path/to/pull-request
[null,null,["2025-08-15 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["\u003cbr /\u003e\n\n2nd gen 1st gen \n\nTrigger a function on TestMatrix completion\n\nCreate a new function that triggers when a TestMatrix completes with the event handler\n`functions.testLab.testMatrix().onComplete()`: \n\n exports.sendEmailNotification = functions.testLab.testMatrix().onComplete((testMatrix) =\u003e {\n // ...\n });\n\nHandle test states and outcomes\n\nEach execution of your function is passed a [`TestMatrix`](/docs/reference/functions/firebase-functions.testlab.testmatrix)\nwhich includes the final state of the matrix and details to help understand problems. \n\n exports.handleTestMatrixCompletion = functions.testLab.testMatrix().onComplete(testMatrix =\u003e {\n const matrixId = testMatrix.testMatrixId;\n switch (testMatrix.state) {\n case 'FINISHED':\n console.log(`TestMatrix ${matrixId} finished with outcome: ${testMatrix.outcomeSummary}`);\n break;\n case 'INVALID':\n console.log(`TestMatrix ${matrixId} was marked as invalid: ${testMatrix.invalidMatrixDetails}`);\n break;\n default:\n console.log(`TestMatrix ${matrixId} completed with state ${testMatrix.state}`);\n }\n return null;\n });\n\nAccess client details\n\nTest matrices may be created from different sources or workflows. It is therefore often desirable to\ncreate functions that perform different actions based on the source or other important context of\nthe test. To help with this, `gcloud` allows you to pass arbitrary information when starting a test\nthat can be accessed later in your function. For example: \n\n gcloud beta firebase test android run \\\n --app=path/to/app.apk \\\n --client-details testType=pr,link=https://path/to/pull-request\n\nExample function: \n\n exports.notifyOnPullRequestFailure = functions.testLab.testMatrix().onComplete(testMatrix =\u003e {\n if (testMatrix.clientInfo.details['testType'] != 'pr') {\n // Not a pull request\n return null;\n }\n\n if (testMatrix.state == 'FINISHED' && testMatrix.outcomeSummary == 'SUCCESS') {\n // No failure\n return null;\n }\n\n const link = testMatrix.clientInfo.details['link'];\n let message = `Test Lab validation for pull request ${link} failed. `;\n\n if (!!testMatrix.resultStorage.resultsUrl) {\n message += `Test results available at ${testMatrix.resultStorage.resultsUrl}. `;\n }\n\n // Send notification here ...\n });"]]