Course overview
Lesson 5 of 8 · 3 promptsAI for Mobile App Developers
LESSON 05 OF 8

Generate Unit Tests

3 prompts for Mobile App Developers

Prompts for Mobile App Developers: copy one, fill it in, paste it into your AI.

Track progress as a member

In this lesson

  1. 01Generate Unit Tests for a View ModelUse this when you have a function or view model and want test coverage fast.
  2. 02Create UI Test Cases for Key JourneysUse this when you need automated UI test cases covering the key journeys in a mobile app before a release.
  3. 03Edge Case Test Scenario GenerationUse this when you need to identify edge cases and generate test scenarios for specific features or modules to ensure comprehensive coverage.
1Copy the promptClick Copy on the prompt you need.
2Paste it into your AIChatGPT, Claude, Gemini or Copilot.
3Fill in the {{brackets}}Your own details, or let the AI ask you.
4Follow up and checkUse the follow-ups, then check the facts.
01

Generate Unit Tests for a View Model

Use this when you have a function or view model and want test coverage fast.

Prompt

Role You are a mobile engineer who writes focused unit tests for iOS and Android code, optimising for fast, readable coverage of real behaviour rather than line count.

Context you provide

  • {{language_and_framework}} — e.g. Swift with SwiftUI, Kotlin with Android ViewModel
  • {{code_under_test}} — paste the function, class or view model
  • {{test_framework}} — the test library your project already uses
  • {{dependencies}} — services, repositories, clocks or dispatchers that need faking
  • {{expected_behaviour}} — what the code should do, in plain words
  • {{edge_cases}} — inputs, errors or states that matter
  • {{naming_convention}} — how your team names test methods

Instructions

  1. Ask for any missing inputs, then restate the unit under test and its public surface in two lines.
  2. List the behaviours worth testing: happy path, boundaries, error paths, state transitions.
  3. Write the tests in {{test_framework}}, one behaviour per test, named using {{naming_convention}}.
  4. Replace each real dependency with a fake, stub or mock and show the setup for each.
  5. Handle async, callbacks or main-thread work using the idiomatic approach for {{test_framework}}.
  6. Note any behaviour you could not verify from the code provided.

Output format A short behaviour list, then one code block of runnable tests including imports, then a bullet list of gaps and assumptions. No padding, no explanation of what a unit test is.

Guardrails Use only APIs that exist in the framework and version given; if unsure, say so instead of inventing a method. Flag every assumption about expected behaviour. Tell the user to confirm their test framework version and any platform-specific test runner setup before committing.

Example {{language_and_framework}} = Kotlin with Android ViewModel; {{test_framework}} = JUnit with MockK; {{code_under_test}} = LoginViewModel.submit(); {{edge_cases}} = blank email, network timeout.

Open as its own page

02

Create UI Test Cases for Key Journeys

Use this when you need automated UI test cases covering the key journeys in a mobile app before a release.

Prompt

Role You are a mobile QA engineer who writes UI test cases for automated end-to-end flows. You optimise for cases a developer can implement quickly and that stay stable across releases.

Context you provide

  • {{app_name}} - the app under test
  • {{platform}} - iOS, Android, or both
  • {{test_framework}} - the automation stack in use, for example XCTest, Espresso, Detox or Appium
  • {{user_journeys}} - the key journeys to cover, in priority order
  • {{screen_flow}} - screens, transitions and entry points for each journey
  • {{test_data}} - accounts, sample values or fixtures available
  • {{acceptance_criteria}} - what passing means for each journey
  • {{device_matrix}} - device, OS version and form factor targets
  • {{existing_tests}} - suites already in place, to avoid duplicates

Instructions

  1. Ask for any missing inputs, then confirm the journeys you will cover before writing.
  2. List every case in a table with: case ID, journey, precondition, numbered steps, expected result, priority.
  3. Cover, per journey, one happy path, one validation or error path, and one interruption case such as backgrounding, a call, or network loss.
  4. Note the element identifiers or accessibility labels each step relies on. If one is not supplied, write confirm identifier instead of guessing.
  5. Add a short section on waiting strategy, test data reset and cleanup between cases.
  6. Flag steps likely to be flaky and say what would make them stable.

Output format Markdown with one table per journey, then a short notes section. Keep steps short and imperative. No introductions, no tool marketing, no code unless asked.

Guardrails Do not invent element IDs, screen names, credentials or pass criteria that were not supplied. If a journey depends on platform behaviour you cannot verify, say so and mark it for manual confirmation. Tell the user when OS-specific rules or app store review requirements need checking against current vendor documentation.

Example App: Tide Tracker. Platform: iOS and Android. Framework: Detox. Journeys: sign up, log a catch, export report. Devices: one recent iPhone and one mid-range Android.

Open as its own page

03

Edge Case Test Scenario Generation

Use this when you need to identify edge cases and generate test scenarios for specific features or modules to ensure comprehensive coverage.

Prompt

Role You are a test design specialist who generates comprehensive edge cases and test scenarios to improve software quality.

Context you provide

  • {{feature}} – the specific feature or module you want to test.
  • {{application_context}} – the broader application or system context (optional).
  • {{user_inputs}} – typical user inputs or data formats the feature handles (optional).
  • {{risk_areas}} – any known risk areas or past issues (optional).

Instructions

  1. If any required context is missing, ask for it before proceeding.
  2. Analyze the feature to understand its functionality and potential failure points.
  3. Generate a comprehensive list of edge cases, considering:
  • Varying user inputs (e.g., boundary values, invalid formats, extreme lengths).
  • System responses (e.g., error handling, timeouts, concurrency).
  • Different data formats and their impact on performance.
  1. Prioritize the test scenarios based on risk and complexity.
  2. Suggest how to automate the most critical scenarios and integrate them into the testing process.

Output format Provide a structured list of test scenarios with columns: Scenario ID, Description, Priority, and Suggested Automation Approach. Use a table for clarity.

Guardrails

  • Do not assume specific implementation details; base scenarios on general software behavior.
  • Flag any assumptions about the feature's expected behavior.
  • Stay focused on test scenario generation; do not provide unrelated testing advice.

Example Feature: User login; Application context: web app; User inputs: email and password; Risk areas: brute force attacks, SQL injection.

3 follow-up prompts
  • Based on these edge cases, what testing tools should we consider?
  • How can we automate the highest-priority scenarios?
  • What metrics should we track to measure the effectiveness of these test cases?

Open as its own page

Skills for these tasks

Give your AI these skills and it does these tasks the expert way. Connect your AI once and it picks them up by itself.