با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
ایجاد سفرها برای Android Studio به شما کمک میکند تا با استفاده از زبان طبیعی برای توصیف مراحل و ادعاهای هر آزمون - که سفر نامیده میشود - نوشتن و نگهداری تستهای سرتاسر را آسان کنید. با استفاده از قابلیتهای بینایی و استدلال Gemini، مراحل نوشته شده به زبان طبیعی به اقداماتی تبدیل میشوند که Gemini در برنامه شما انجام میدهد و نوشتن و درک سفرهای شما را آسان میکند. بهعلاوه، میتوانید ادعاهای پیچیدهتری را بنویسید و توصیف کنید، که Gemini آنها را بر اساس آنچه در دستگاه میبیند ارزیابی میکند تا تشخیص دهد که آیا سفر شما انجام میشود یا ناموفق.
و از آنجایی که Gemini در مورد اقداماتی که باید برای برآورده کردن اهداف انجام شود، توضیح میدهد، سفرها در برابر تغییرات ظریف در چیدمان یا رفتار برنامه شما انعطافپذیرتر هستند و در نتیجه هنگام اجرای نسخههای مختلف برنامه و پیکربندیهای مختلف دستگاه، تستهای پوستهپوسته کمتری انجام میشود.
سفرها را مستقیماً از Android Studio در برابر هر دستگاه Android محلی یا راه دور بنویسید و اجرا کنید. IDE یک تجربه ویرایشگر جدید برای ساخت سفرها و همچنین نتایج غنی ارائه می دهد که به شما کمک می کند استدلال Gemini و اجرای سفر خود را بهتر دنبال کنید.
سفری بنویس
Android Studio یک قالب فایل و تجربه ویرایشگر جدید را ارائه می دهد که ایجاد و ویرایش سفرها را آسان می کند. سفرها با استفاده از نحو XML برای سازماندهی شرح سفر و مراحل شما نوشته می شوند.
برای ایجاد و شروع ویرایش سفر، موارد زیر را انجام دهید:
از پانل پروژه در اندروید استودیو، روی ماژول برنامه ای که می خواهید سفری برای آن بنویسید کلیک راست کنید.
New > Test > Journey File را انتخاب کنید.
در گفتگوی ظاهر شده، نام و شرح سفر خود را ارائه دهید.
روی OK کلیک کنید. Android Studio یک فایل XML برای سفر شما با نامی که شما انتخاب کرده اید ایجاد می کند. میتوانید از نمای کد برای ویرایش مستقیم XML یا نمای طراحی برای بهبود تجربه ویرایش استفاده کنید.
هنگام مشاهده سفر خود در نمای طراحی ، از فیلد متنی برای توصیف هر مرحله از سفر خود استفاده کنید. هر مرحله می تواند شامل اقدامات توصیفی باشد که می خواهید Gemini انجام دهد یا اظهاراتی که می خواهید Gemini آنها را ارزیابی کند.
Enter را روی صفحه کلید خود فشار دهید تا در همان سفر یک درخواست جدید شروع شود. می توانید این کار را در صورت نیاز برای هر مرحله از سفری که می خواهید تعریف کنید تکرار کنید.
نکاتی برای نوشتن سفر
نوشتن سفرهای خود به روشی دقیق و سازماندهی شده می تواند احتمال اینکه Gemini سفرهای مورد نظر شما را با دقت بیشتری انجام دهد را افزایش می دهد. در اینجا چند نکته وجود دارد که به شما کمک می کند تا سفرهای خود را موثرتر بنویسید:
ادعاها را از اقدامات جدا کنید: Gemini دائماً وضعیت برنامه شما را ارزیابی می کند تا مشخص کند آیا برای ادامه سفر در وضعیت "صحیح" است یا خیر. با این حال، ممکن است لازم باشد که ادعاهای پیچیده تری را به عنوان یک مرحله جداگانه تعریف کنید. بهعلاوه، هر درخواست را با استفاده از عبارات کلیدی مانند «تأیید کنید»، «اظهار کنید» یا «بررسی کنید» شروع کنید تا به جمینی بفهمانید که این مرحله یک ادعا است.
Gemini مستقیم با کشیدن انگشت: علاوه بر تعاملات اساسی، مانند ضربه زدن یا ورودی های صفحه کلید، Gemini از اقداماتی پشتیبانی می کند که لازم است صفحه را در جهت های خاصی بکشد. به عنوان مثال، برای پیمایش در محتوا یا رد کردن برخی از UI، به سادگی جهت و هدف عمل کشیدن انگشت خود را توصیف کنید. بهطور پیشفرض، Gemini از مرکز صفحهنمایش سوایپ میکند، اما میتوانید آن را برای کشیدن انگشت روی قسمت دیگری از صفحه نمایش دستگاه راهنمایی کنید.
اجتناب از تعاملات پیچیده و تغییرات پیکربندی: Gemini در حال حاضر از همه تعاملات و تغییرات پیکربندی، مانند حرکات چند انگشتی، چرخش صفحه، یا کنش های تاشو پشتیبانی نمی کند. این تیم برای بهبود قابلیت های Gemini کار می کند.
سفر خود را اجرا کنید
میتوانید سفر خود را بر روی هر دستگاه محلی یا راه دور موجود، مشابه هر آزمایش ابزاردار دیگری اجرا کنید، و Android Studio نتایج غنی تولید میکند که به شما در درک نحوه اجرای سفرتان کمک میکند.
برای آزمایش یک سفر، موارد زیر را انجام دهید:
یک دستگاه مورد نظر را از نوار ابزار اصلی انتخاب کنید، مانند زمانی که یک تست ابزار دقیق را اجرا می کنید.
به فایل سفر XML که میخواهید آزمایش کنید بروید و آن را در ویرایشگر باز کنید.
در ویرایشگر یکی از موارد زیر را انجام دهید:
اگر در نمای طراحی هستید، کلیک کنید Run Journey
اگر در نمای کد هستید، کلیک کنید اجرا کنید در ناودان کنار جایی که نام سفر در XML تعریف شده است.
Android Studio پیکربندی Journeys Test را برای شما ایجاد می کند و آن را روی دستگاه مورد نظر اجرا می کند. در حین اجرا، Android Studio برنامه شما را ساخته و اجرا میکند و به Gemini متصل میشود تا مشخص کند برای هر مرحله از سفرتان چه اقداماتی باید انجام دهید.
نتایج محدودی نیز در ویرایشگر در حین اجرای یک سفر نشان داده میشود، مانند اسکرینشاتها، اقدامات انجامشده و استدلال در طول اجرای هر مرحله از سفر شما. برای مشاهده اطلاعات بیشتر، کافیست ماوس را روی تصویر کوچک در ویرایشگر نگه دارید. این می تواند هنگام تکرار دستورات در سفر مفید باشد.
مشاهده نتایج
وقتی Android Studio آزمایش سفر شما را کامل کرد، پانل نتایج آزمایش به طور خودکار ظاهر می شود تا نتایج را به شما نشان دهد.
در مقایسه با سایر تستهای ابزاری که ممکن است در Android Studio اجرا کنید، تفاوتهایی در نحوه نمایش نتایج سفرها وجود دارد.
پانل تست ها سفر را به مراحل گسسته تقسیم می کند. می توانید روی هر مرحله کلیک کنید تا اطلاعات بیشتری در مورد نحوه اجرای Gemini پیدا کنید.
پانل نتایج اطلاعات غنی را نشان می دهد تا به شما کمک کند بفهمید Gemini چگونه سفر شما را درک کرده و درباره آن استدلال می کند و چگونه آن را اجرا کرده است.
اسکرین شات هایی که به Gemini ارسال شده اند برای کمک بصری در هر اقدام در مرحله نشان داده می شوند.
هر اقدام انجام شده و استدلال Gemini برای اینکه چرا آن اقدام را انجام داده است در کنار هر اسکرین شات توضیح داده شده است.
هر عمل در مرحله شماره گذاری می شود.
مسائل شناخته شده
هنگام آزمایش یک سفر، همه مجوزها برای برنامه شما به طور پیش فرض اعطا می شود.
هنگام آزمایش سفر در دستگاهی که دارای Android 15 (سطح API 35) است، ممکن است اخطاری را در دستگاه مشاهده کنید که میگوید «برنامه ناامن مسدود شده است» برای «AndroidX Crawler». برای دور زدن این بررسی می توانید به هر حال روی Install کلیک کنید. همچنین، میتوانید گزینههای برنامهنویس روی دستگاه را پیکربندی کنید و گزینه تأیید برنامهها از طریق USB را غیرفعال کنید.
فایلهای Journey در حال حاضر در نمای Android در پانل پروژهها ظاهر نمیشوند. برای مشاهده فایل های سفر در پروژه خود، از نمای پروژه استفاده کنید.
اگر چندین عملکرد در یک سفر دقیقاً همان فرمان را به اشتراک بگذارند، نتایج آزمایشی که در ویرایشگر سفر نمایش داده میشود ممکن است نادرست باشد. به طور خاص، همه اقدامات با درخواست تکراری، نتایج آزمایش مرتبط با آخرین نمونه بهروزرسانیشده آن درخواست را نشان میدهند. برای حل این مشکل، اطمینان حاصل کنید که هر عملکرد یک دستور منحصر به فرد دارد - به عنوان مثال، با افزودن یک پیشوند یا پسوند مجزا.
دومین باری که صفحه کلید روی یک شبیه ساز تازه بارگذاری می شود، یک پنجره بازشو قلم ظاهر می شود. این پاپ آپ معمولا باعث می شود تست هایی که با فیلدهای متنی تعامل دارند با شکست مواجه شوند. وقتی این اتفاق افتاد، پنجره بازشو را رد کنید و سفر را دوباره اجرا کنید.
ممکن است گاهی اوقات مصنوعات خزنده برنامه در منطق عامل ظاهر شوند.
اجرای سفر گاهی اوقات با یک IllegalStateException با شکست مواجه می شود. هنگامی که این اتفاق می افتد، می توانید روی نتایج تست کلیک کنید تا خطای کامل را ببینید.
اگر افزونه Android Gradle ( com.android.application ) در فایل build.gradle سطح بالا تعریف نشده باشد، ممکن است هنگام اجرای سفر با خطای زیر مواجه شوید:
Failed to apply plugin class 'com.android.tools.journeys.JourneysGradlePlugin'
برای حل این مشکل، مطمئن شوید که افزونه در فایل build.gradle سطح بالا تعریف شده است. برای اطلاعات بیشتر به پیکربندی سیستم ساخت اندروید مراجعه کنید.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-08-09 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-08-09 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Journeys for Android Studio\n\n| **Preview:** Journeys for Android Studio are available starting from Android Studio Narwhal Feature Drop \\| 2025.1.3.\n\nCreating journeys for Android Studio helps make end-to-end tests easy to write\nand maintain by letting you use natural language to describe the steps and\nassertions for each test---called a journey. By leveraging Gemini's vision and\nreasoning capabilities, steps written in natural language are converted into\nactions that Gemini performs on your app, making it both easy to write and\nunderstand your journeys. Additionally, you can write and describe more complex\nassertions, which Gemini evaluates based on what it sees on the device in order\nto determine whether your journeys pass or fail. \n\nAnd because Gemini reasons about which actions to perform to satisfy the goals,\njourneys are more resilient to subtle changes to your app's layout or behavior,\nresulting in fewer flaky tests when running against different versions of your\napp and different device configurations.\n\nWrite and run journeys right from Android Studio against any local or remote\nAndroid device. The IDE provides a new editor experience for crafting journeys\nas well as rich results that help you better follow Gemini's reasoning and\nexecution of your journey.\n| **Note:** Before you get started, download the latest [Canary version of Android\n| Studio](/studio/preview). You'll also need to make sure that you're signed into your developer account and have enabled Gemini in Android Studio.\n\nWrite a journey\n---------------\n\nAndroid Studio provides a file template and new editor experience that makes\ncreating and editing journeys easy. Journeys are written using the XML syntax to\norganize your journey description and steps.\n\nTo create and start editing a journey, do the following:\n\n1. From the **Project** panel in Android Studio, right-click on the app module for which you want to write a journey.\n2. Select **New \\\u003e Test \\\u003e Journey File**.\n3. In the dialog that appears, provide the name and description of your journey.\n4. Click **OK** . Android Studio creates an XML file for your journey with the name you chose. You can use either the **Code** view to edit the XML directly, or the **Design** view for an improved editing experience.\n5. When viewing your journey in the **Design** view, use the text field to describe each step of your journey. Each step can include descriptive actions you want Gemini to perform or assertions that you want Gemini to evaluate.\n6. Press \u003ckbd\u003eEnter\u003c/kbd\u003e on your keyboard to start a new prompt in the same journey. You can repeat this as needed for each step of the journey you want to define.\n\n### Tips for writing journeys\n\nWriting your journeys in a detailed and organized way can increase the\nlikelihood of Gemini accurately running your intended journeys in a more\ndeterministic way. Here are some tips to help you write your journeys more\neffectively:\n\n- **Separate assertions from actions:** Gemini constantly evaluates the state of your app to determine if it's in a \"correct\" state to continue the journey. However, you might need to define more complex assertions as a separate step. Additionally, start each prompt using key phrases such as \"Verify that,\" \"Assert that,\" or \"Check that\" to let Gemini know that this step is meant to be an assertion.\n- **Direct Gemini with swipes:** In addition to basic interactions, such as tapping or keyboard inputs, Gemini supports actions that require it to swipe the screen in certain directions. For example, to scroll through content or dismiss some UI simply describe the direction and intent of your swipe action. By default, Gemini swipes from the center of the screen, but you can guide it to swipe on a different part of the device screen.\n- **Avoid complex interactions and configuration changes:** Gemini currently does not support all interactions and configuration changes, such as multi-finger gestures, screen rotations, or folding actions. The team is working to improve Gemini capabilities.\n\nRun your journey\n----------------\n\nYou can run your journey on any available local or remote device, similar to any\nother instrumented test, and Android Studio generates rich results that help you\nunderstand the execution of your journey.\n\nTo test a journey, do the following:\n\n1. Select a target device from the main toolbar, like you would when running an instrumented test.\n2. Navigate to the journey XML file that you would like to test and open it in the editor.\n3. In the editor, do one of the following:\n 1. If you're in the **Design** view, click **Run Journey**.\n 2. If you're in the **Code** view, click **Run** in the gutter next to where the name of the journey is defined in the XML.\n\nAndroid Studio creates a **Journeys Test** configuration for you and runs it on\nthe target device. During execution, Android Studio builds and deploys your app,\nand connects to Gemini to determine which actions to take for each step of your\njourney.\n\nLimited results are also shown in the editor while running a journey, such as\nthe screenshots, action taken, and reasoning during the execution of each step\nin your journey. Simply hover over the thumbnail in the editor to see more\ninformation. This can be helpful when iterating on the prompts in your journey.\n\nView results\n------------\n\nWhen Android Studio completes testing your journey, the test results panel\nappears automatically to show you the results.\n\nCompared to other instrumented tests you might run in Android Studio, there are\nsome differences in how results for journeys are displayed.\n\n- The **Tests** panel breaks down the journey into the discrete steps. You can click on each step to find out more information about how Gemini executed it.\n- The **Results** panel shows rich information to help you understand how Gemini understood and reasoned about your journey, and how it was executed.\n- The screenshots that were sent to Gemini are shown for visual aid at each action in the step.\n- Each action taken and Gemini's reasoning for why it took that action is described next to each screenshot.\n- Each action in the step is numbered.\n\nKnown issues\n------------\n\n- When testing a journey, all permissions for your app are granted by default.\n- When testing a journey on a device running Android 15 (API level 35), you might see a warning on the device that says \"Unsafe App Blocked\" for \"AndroidX Crawler\". You can click **Install anyway** to bypass this check. Alternatively, you can [Configure on-device developer options](/studio/debug/dev-options) and disable the option to **Verify apps over USB**.\n- Journey files do not currently appear in the **Android** view in the **Projects** panel. To see journey files in your project, use the **Project** view.\n- If multiple actions within a journey share the exact same prompt, the test results displayed in the journey editor may be incorrect. Specifically, all actions with the duplicate prompt will show the test results associated with the most recently updated instance of that prompt. To work around this, ensure each action has a unique prompt---for example, by adding a distinct prefix or suffix.\n- A stylus popup appears the second time the keyboard is loaded on a fresh emulator. This popup usually causes tests that interact with text fields to fail. When this occurs, dismiss the popup and rerun the journey.\n- App crawler artifacts might occasionally appear in agent rationale.\n- Journey execution occasionally fails with an `IllegalStateException`. When this happens, you can click on **Test Results** to see the full error.\n- If the Android Gradle Plugin (`com.android.application`) isn't defined in the\n top-level `build.gradle` file, you may see the following error when running a\n journey:\n\n Failed to apply plugin class 'com.android.tools.journeys.JourneysGradlePlugin'\n\n To resolve this, ensure that the plugin is defined in the top-level\n `build.gradle` file. See [Configure the Android build system](/build#top-level)\n for more information."]]