יצירת תרחישים של בדיקת יחידה
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
כשכותבים בדיקות יחידה לאפליקציה, Gemini יכול להציע תרחישי בדיקה על סמך ההקשר של הקוד שרוצים לבדוק. כשמייצרים תרחישים לבדיקות יחידה, Gemini כולל שמות ותיאורים מפורטים לבדיקות, כדי שתוכלו להבין טוב יותר את הכוונה של כל בדיקה מוצעת. צריך להטמיע את גוף הבדיקה של כל בדיקה בעצמכם.
כדי ליצור תרחישי בדיקה ליחידות:
- עוברים לכיתה שרוצים ליצור עבורה תרחישי בדיקה.
- לוחצים לחיצה ימנית על שם הכיתה ובוחרים באפשרות Gemini > Generate Unit Test Scenarios (Gemini > יצירת תרחישי בדיקת יחידות) בתפריט ההקשר.
- בתיבת הדו-שיח שמופיעה, בוחרים את השיטות של הכיתה שרוצים ליצור עבורן תרחישים, ומגדירים את חבילת היעד לבדיקות.
- לוחצים על אישור.
- מאשרים את ספריית היעד של הבדיקות ולוחצים על אישור.
- אם מחלקת הבדיקה כבר קיימת, צריך לאשר אם רוצים ש-Gemini יציע עדכונים לקובץ הקיים.
אחרי ש-Gemini מעבד את הבקשה, אמור להופיע קובץ חדש עם בדיקות היחידה המוצעות, או קובץ השוואה שבו אפשר לאשר את השינויים המומלצים בקובץ קיים.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-31 (שעון UTC).
[[["התוכן קל להבנה","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-07-31 (שעון UTC)."],[],[],null,["# Generate unit test scenarios\n\nWhen writing unit tests for your app, Gemini can suggest test scenarios using\nthe context of the code you want to test. When generating unit test scenarios,\nGemini includes detailed names and descriptions for your tests, so that you\nbetter understand the intention for each suggested test. You need to implement\nthe body of each test yourself.\n\nTo generate unit test scenarios, do the following:\n\n1. Navigate to the class you want to generate unit test scenarios for.\n2. Right-click on the class name and select **Gemini \\\u003e Generate Unit Test Scenarios** from the context menu.\n3. In the dialog that appears, select the methods of the class that you want to generate scenarios for, and set the destination package for the tests.\n4. Click **OK**.\n5. Confirm the destination directory for your tests and click **OK**.\n6. If the test class already exists, confirm whether you want Gemini to suggest updates to the existing file.\n\nAfter Gemini processes the request, you should see either a new file with the\nsuggested unit tests or a diff for you to accept recommended changes to an\nexisting file."]]