تست کردن
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
آزمایش یک گام مهم در ایجاد یک ادغام موفقیت آمیز Google Ads API است، چه تازه شروع کرده باشید، چه از یک برنامه نگهداری کنید یا ویژگی های جدیدی را به یک ادغام موجود اضافه کنید. این راهنما برخی از بهترین روشها را برای آزمایش یکپارچهسازی Google Ads API ارائه میکند.
حساب های آزمایشی و حساب های تولید
حساب های آزمایشی برای اهداف توسعه در دسترس هستند. با استفاده از حسابهای آزمایشی، میتوانید تأیید کنید که کد برنامه و پیکربندی شما طبق برنامه کار میکند.
با این حال، همه ویژگی ها را نمی توان در یک حساب کاربری آزمایشی آزمایش کرد.
وقتی محدودیتهای حساب آزمایشی مانع از آزمایش برخی ویژگیها در یکپارچهسازی شما میشود، میتوانید در عوض از یک حساب تولید برای توسعه استفاده کنید. حساب های تولید برای توسعه با حساب های آزمایشی به روش های زیر متفاوت است:
- تبلیغاتی را ارائه دهید که توسط کاربران قابل مشاهده باشد
- نیاز به URL های معتبر
- باید با سیاست های تبلیغاتی مطابقت داشته باشد
از آنجایی که حسابهای تولیدی تبلیغات را ارائه میکنند، معیارهایی تولید میکنند که به شما امکان میدهد گزارشهای عملکرد را آزمایش کنید، و همچنین قفل سایر ویژگیهای Google Ads API را باز کنید. با این حال، استفاده از آنها برای توسعه نیاز به احتیاط بیشتری دارد. توصیه می کنیم اقدامات زیر را انجام دهید:
- فقط به کاربرانی که برای اهداف توسعه به آن نیاز دارند دسترسی بدهید.
- یک بودجه حساب روزانه ثابت و کم تنظیم کنید.
- تنها زمانی از حسابهای تولید برای توسعه استفاده کنید که نمیتوان از حسابهای آزمایشی استفاده کرد.
بنابراین، برای انجام آزمایش کامل ادغام خود، احتمالاً به اعتبارنامه آزمایشی و اعتبارنامه تولید نیاز خواهید داشت.
مدارک آزمایشی
برای به حداقل رساندن خطر تغییر تصادفی حسابهای تولید هنگام تلاش برای اصلاح حسابهای توسعه، توصیه میکنیم مجموعهای از اعتبارنامههای آزمایشی را که جدا از اعتبارنامههای برنامه تولید شما هستند، حفظ کنید.
برای ایجاد مجموعه ای از اعتبارنامه های آزمایشی:
- یک حساب ایمیل (به عنوان مثال api.test@example.com) یا یک حساب سرویس ایجاد کنید که فقط برای اهداف آزمایشی استفاده می شود.
- این حساب کاربری یا سرویس را به عنوان یک کاربر معتبر در حسابهای Google Ads که آزمایشهای خود را روی آنها انجام میدهید، اضافه کنید. اطمینان حاصل کنید که سطوح دسترسی مناسب را به این حساب کاربری یا خدمات ارائه میدهید. به این حساب کاربری یا سرویس دسترسی به هیچ حساب تولیدی ندهید.
- اگر از جریان احراز هویت کاربر OAuth 2.0 به جای جریان حساب سرویس استفاده میکنید، یک نشانه تازهسازی برای حساب کاربری آزمایشی خود ایجاد کنید.
- هنگام آزمایش برنامه خود از این اعتبارنامه های جدید استفاده کنید. رمز توسعهدهنده، شناسه مشتری و راز سرویس گیرنده را میتوان برای مقاصد آزمایشی مورد استفاده مجدد قرار داد، زیرا هیچ تأثیری در تعیین اینکه به کدام حسابهای Google Ads میتوان دسترسی داشت، ندارند.
درخواست اعتبار
اگر فقط باید آزمایش کنید که آیا یک درخواست معتبر است - برای مثال، برای تأیید اینکه درخواست به درستی ساختار یافته است و خطمشیها را نقض نمیکند - میتوانید از فیلد validate_only
استفاده کنید که برای درخواستهای GoogleAdsService.SearchStream
و GoogleAdsService.Search
و همچنین بیشتر درخواستهای جهشیافته در دسترس است. برای بررسی اینکه آیا این فیلد برای یک روش مشخص در دسترس است یا خیر، با اسناد مرجع مشورت کنید.
REST API
برای آزمایش موقت، به عنوان مثال برای تأیید اینکه یک درخواست خروجی مورد انتظار را ارائه می دهد، استفاده از REST API اغلب ساده ترین گزینه است. برای یادگیری نحوه استفاده از curl در درخواست به REST API، با مثالهای REST مشورت کنید. همچنین، آزمایش را در اکسپلورر REST امتحان کنید.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-26 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-26 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eTesting is crucial for successful Google Ads API integration, whether you're starting fresh, maintaining an app, or adding features.\u003c/p\u003e\n"],["\u003cp\u003eUtilize test accounts for development when possible, but be aware of their limitations and consider using production accounts cautiously for features not supported by test accounts.\u003c/p\u003e\n"],["\u003cp\u003eMaintain separate test credentials, especially refresh tokens, to avoid accidental modifications to production accounts.\u003c/p\u003e\n"],["\u003cp\u003eValidate your requests using the \u003ccode\u003evalidate_only\u003c/code\u003e field to ensure they are structured correctly and comply with policies.\u003c/p\u003e\n"],["\u003cp\u003eLeverage the REST API for quick, ad hoc testing and validation of request outputs.\u003c/p\u003e\n"]]],[],null,["# Testing is an important step in building a successful Google Ads API integration,\nwhether you're just getting started, maintaining an app, or adding\nnew features to an existing integration. This guide presents some best\npractices for testing your Google Ads API integration.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nTest accounts and production accounts\n-------------------------------------\n\n[Test accounts](/google-ads/api/docs/best-practices/test-accounts) are available for\ndevelopment purposes. With test accounts, you can validate that your application\ncode and configuration are working as intended.\n\nHowever, [not all\nfeatures](/google-ads/api/docs/best-practices/test-accounts#limitations) can be tested in a\ntest account account.\n\nWhen test account limitations prevent you from testing some features in your\nintegration, you can instead use a production account for development.\nProduction accounts for development differ from test accounts in the following\nways:\n\n- Serve ads that can be seen by users\n- Require valid URLs\n- Must comply with [advertising policies](//support.google.com/adspolicy/answer/6008942)\n\nBecause production accounts serve ads, they generate metrics letting you test\nperformance reports, as well as unlocking all the other features of the\nGoogle Ads API. However, using them for development requires extra caution. We\nrecommend taking the following measures:\n\n- Only grant access to users that need it for development purposes.\n- Set a fixed, low daily account budget.\n- Use production accounts for development only when test accounts can't be used.\n\nThus, to do full testing of your integration, you will likely need both test\ncredentials and production credentials.\n\nTest credentials\n----------------\n\nTo minimize the risk of accidentally modifying production accounts when trying\nto modify development accounts, we recommend maintaining a set of test\ncredentials that are separate from your production application credentials.\n\nTo create a set of test credentials:\n\n1. Create an email account (e.g. api.test@example.com) or a service account that will be used only for testing purposes.\n2. Add this user or service account as a valid user in the Google Ads accounts you are running your tests against. Make sure you give appropriate [access levels](//support.google.com/google-ads/answer/9978556) to this user or service account. Don't give this user or service account access to **any production accounts**.\n3. If you are using the [OAuth 2.0 user authentication flow, rather than the\n service account flow](/google-ads/api/docs/get-started/choose-application-type#choose-app-type), then generate a refresh token for your test user account.\n4. Use these new credentials when testing your application. The developer token, client ID, and client secret can be reused for testing purposes, since they have no effect in determining which Google Ads accounts can be accessed.\n\nRequest validation\n------------------\n\nIf you just need to test whether a request is valid---for example, to\nverify that the request is structured correctly and does not violate\npolicies---you can use the\n[`validate_only`](/google-ads/api/docs/concepts/api-structure#mutate_validation)\nfield, which is available for `GoogleAdsService.SearchStream` and\n`GoogleAdsService.Search` requests, as well as most mutate requests.\nConsult the [reference documentation](/google-ads/api/reference/rpc/v21/overview) to verify\nwhether this field is available for a given method.\n\nREST API\n--------\n\nFor ad hoc testing, for example to validate that a request yields the expected\noutput, using the REST API is often the easiest option. Consult the [REST\nexamples](/google-ads/api/rest/examples) to learn how to use curl in making\nrequests to the REST API. Also, try testing in the\n[REST explorer](/google-ads/api/rest/try-it)."]]