Code de la plate-forme de test
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Android Studio pour la plate-forme permet d'exécuter des tests d'appareils locaux (via atest
).
Accédez à un test, puis cliquez sur l'icône Run (Exécuter).
La sortie du test s'affiche dans la fenêtre de la console.
Le contenu et les exemples de code de cette page sont soumis aux licences décrites dans la Licence de contenu. Java et OpenJDK sont des marques ou des marques déposées d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/01/30 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/01/30 (UTC)."],[],[],null,["Android Studio for Platform (ASfP) integrates with the `atest` command-line\ntool, letting you run tests on your connected device or emulator directly from\nthe IDE.\n\nPrerequisites\n\n- Open an ASfP project with your AOSP source code.\n- Successfully build and flash your code to a device or emulator.\n- Initialize your build environment using `source build/envsetup.sh` and `lunch`.\n\nRun tests\n\nYou can run tests using `atest` in ASfP in several ways:\n\n- **Gutter run icons:** Click the **Run** icon play_circle\n\n next to a test class or method in the editor to run that specific test.\n- **Right-click menu:** Right-click on a test file, class, or method in the\n Project window or editor and select **Run 'atest'**.\n\n- **Using the terminal:** Open the integrated terminal in ASfP (**View \\\u003e Tool\n Windows \\\u003e Terminal** ) and run `atest` commands directly. For example: `bash\n atest MyTestModule\n atest MyTestClass#myTestMethod`\n\nView test results\n\nTest results are displayed in the **Run** tool window within ASfP. This window\nshows the test progress, pass or fail status, and provides logs and output for\neach test.\n\nTest configurations\n\nWhen you run a test from the gutter or right-click menu, ASfP automatically\ncreates a temporary run or debug configuration. You can modify and save these\nconfigurations to quickly re-run tests with specific options or flags:\n\n1. Go to **Run \\\u003e Edit Configurations**.\n2. Find the `atest` configuration you want to modify or create a new one by clicking the **+** button and selecting **atest**.\n3. Specify the test module, class, method, and add any necessary `atest` command-line options.\n\nTips for testing\n\n- **Targeted testing:** Run only the specific tests you need to save time. Use the format `Module:Class#Method` or other `atest` filters.\n- **Use emulator snapshots:** For faster test runs on emulators, consider using snapshots to quickly revert to a known good state.\n- **Check logs:** Use the logs in the **Run** tool window to diagnose any test failures."]]