Mobile App Testing

VerifiedSafe

Provides comprehensive testing strategies for iOS and Android mobile apps including unit, UI, integration, and performance tests. Automates testing with Detox for React Native, XCTest for native iOS, and Appium for cross-platform scenarios. Helps ensure code quality, catch regressions, and validate user flows before release.

Sby Skills Guide Bot
TestingIntermediate
2/28/2026
Claude CodeCursorWindsurfCopilotCodex
#mobile-testing#detox#xctest#react-native#e2e-testing

Recommended for

Automated summary

This skill provides testing strategies and code samples for iOS and Android mobile apps, covering unit tests, component tests, E2E tests and integration using Jest, Detox and XCTest.

Strengths

  • Ready-to-reuse code samples for Jest, React Native Testing Library and Detox, including both success and failure cases
  • XCTest patterns showing mocked network service injection and assertions on ViewModel state
  • Spans unit-level tests as well as E2E flows such as login and tab navigation
  • Numbered, step-based structure that is easy for an agent to follow

Limitations

  • Appium and performance testing are named in the description but never demonstrated with examples
  • The Swift snippet is truncated (MockNetworkService class incomplete) and cannot be copied as-is
  • No guidance on project wiring, CI runners or test reporting
When to use it

Use it when you need to write or extend a test suite for a React Native app or a native iOS/Android app.

When not to use it

Skip it if you need full Appium setup, mobile load/performance testing, or an end-to-end CI pipeline.

Security analysis

Safe
Quality score80/100

The skill is purely instructional documentation for mobile testing frameworks (Jest/Detox, XCTest, Espresso). It contains no shell commands, no network or filesystem operations, no credential handling, and no instructions that could be executed destructively. All code blocks are illustrative test snippets with placeholder credentials. There is no meaningful execution risk.

No concerns found

How this analysis is made

Examples

Add Detox E2E tests
Write Detox E2E tests for my React Native app's signup flow: fill the form, submit, and verify the welcome screen appears, plus a test for the duplicate-email error message.
Unit test a React Native component
Create Jest + React Native Testing Library tests for my CheckoutSummary component, covering the populated cart and the empty-cart state.
XCTest with mocks
Generate XCTest cases for my Swift ProfileViewModel, injecting a mocked network service to test both a successful fetch and a failure that sets errorMessage.

name: mobile-app-testing description: Comprehensive mobile app testing strategies for iOS and Android. Covers unit tests, UI tests, integration tests, performance testing, and test automation with Detox, Appium, and XCTest.

Mobile App Testing

Overview

Implement comprehensive testing strategies for mobile applications including unit tests, UI tests, integration tests, and performance testing.

When to Use

  • Creating reliable mobile applications with test coverage
  • Automating UI testing across iOS and Android
  • Performance testing and optimization
  • Integration testing with backend services
  • Regression testing before releases

Instructions

1. React Native Testing with Jest & Detox

// Unit test with Jest
import { calculate } from '../utils/math';

describe('Math utilities', () => {
  test('should add two numbers', () => {
    expect(calculate.add(2, 3)).toBe(5);
  });

  test('should handle negative numbers', () => {
    expect(calculate.add(-2, 3)).toBe(1);
  });
});

// Component unit test
import React from 'react';
import { render, screen } from '@testing-library/react-native';
import { UserProfile } from '../components/UserProfile';

describe('UserProfile Component', () => {
  test('renders user name correctly', () => {
    const mockUser = { id: '1', name: 'John Doe', email: 'john@example.com' };
    render(<UserProfile user={mockUser} />);

    expect(screen.getByText('John Doe')).toBeTruthy();
  });

  test('handles missing user gracefully', () => {
    render(<UserProfile user={null} />);
    expect(screen.getByText(/no user data/i)).toBeTruthy();
  });
});

// E2E Testing with Detox
describe('Login Flow E2E Test', () => {
  beforeAll(async () => {
    await device.launchApp();
  });

  beforeEach(async () => {
    await device.reloadReactNative();
  });

  it('should login successfully with valid credentials', async () => {
    await waitFor(element(by.id('emailInput')))
      .toBeVisible()
      .withTimeout(5000);

    await element(by.id('emailInput')).typeText('user@example.com');
    await element(by.id('passwordInput')).typeText('password123');
    await element(by.id('loginButton')).multiTap();

    await waitFor(element(by.text('Home Feed')))
      .toBeVisible()
      .withTimeout(5000);
  });

  it('should show error with invalid credentials', async () => {
    await element(by.id('emailInput')).typeText('invalid@example.com');
    await element(by.id('passwordInput')).typeText('wrongpass');
    await element(by.id('loginButton')).multiTap();

    await waitFor(element(by.text(/invalid credentials/i)))
      .toBeVisible()
      .withTimeout(5000);
  });

  it('should navigate between tabs', async () => {
    await element(by.id('profileTab')).tap();
    await waitFor(element(by.text('Profile')))
      .toBeVisible()
      .withTimeout(2000);

    await element(by.id('homeTab')).tap();
    await waitFor(element(by.text('Home Feed')))
      .toBeVisible()
      .withTimeout(2000);
  });
});

2. iOS Testing with XCTest

import XCTest
@testable import MyApp

class UserViewModelTests: XCTestCase {
  var viewModel: UserViewModel!
  var mockNetworkService: MockNetworkService!

  override func setUp() {
    super.setUp()
    mockNetworkService = MockNetworkService()
    viewModel = UserViewModel(networkService: mockNetworkService)
  }

  func testFetchUserSuccess() async {
    let expectedUser = User(id: UUID(), name: "John", email: "john@example.com")
    mockNetworkService.mockUser = expectedUser

    await viewModel.fetchUser(id: expectedUser.id)

    XCTAssertEqual(viewModel.user?.name, "John")
    XCTAssertNil(viewModel.errorMessage)
    XCTAssertFalse(viewModel.isLoading)
  }

  func testFetchUserFailure() async {
    mockNetworkService.shouldFail = true

    await viewModel.fetchUser(id: UUID())

    XCTAssertNil(viewModel.user)
    XCTAssertNotNil(viewModel.errorMessage)
    XCTAssertFalse(viewModel.isLoading)
  }
}

class MockNetworkService: NetworkService {
  var mockUser: User?
  var shouldFail = false

  override func fetch<T: Decodable>(
    _: T.Type,
    from endpoint: String
  ) async throws -> T {
    if shouldFail {
      throw NetworkError.unknown
    }
    return mockUser as! T
  }
}

// UI Test
class LoginUITests: XCTestCase {
  override func setUp() {
    super.setUp()
    continueAfterFailure = false
    XCUIApplication().launch()
  }

  func testLoginFlow() {
    let app = XCUIApplication()

    let emailTextField = app.textFields["emailInput"]
    let passwordTextField = app.secureTextFields["passwordInput"]
    let loginButton = app.buttons["loginButton"]

    emailTextField.tap()
    emailTextField.typeText("user@example.com")

    passwordTextField.tap()
    passwordTextField.typeText("password123")

    loginButton.tap()

    let homeText = app.staticTexts["Home Feed"]
    XCTAssertTrue(homeText.waitForExistence(timeout: 5))
  }

  func testNavigationBetweenTabs() {
    let app = XCUIApplication()
    let profileTab = app.tabBars.buttons["Profile"]
    let homeTab = app.tabBars.buttons["Home"]

    profileTab.tap()
    XCTAssertTrue(app.staticTexts["Profile"].exists)

    homeTab.tap()
    XCTAssertTrue(app.staticTexts["Home"].exists)
  }
}

3. Android Testing with Espresso

@RunWith(AndroidJUnit4::class)
class UserViewModelTest {
  private lateinit var viewModel: UserViewModel
  private val mockApiService = mock<ApiService>()

  @Before
  fun setUp() {
    viewModel = UserViewModel(mockApiService)
  }

  @Test
  fun fetchUserSuccess() = runTest {
    val expectedUser = User("1", "John", "john@example.com")
    `when`(mockApiService.getUser("1")).thenReturn(expectedUser)

    viewModel.fetchUser("1")

    assertEquals(expectedUser.name, viewModel.user.value?.name)
    assertEquals(null, viewModel.errorMessage.value)
  }

  @Test
  fun fetchUserFailure() = runTest {
    `when`(mockApiService.getUser("1"))
      .thenThrow(IOException("Network error"))

    viewModel.fetchUser("1")

    assertEquals(null, viewModel.user.value)
    assertNotNull(viewModel.errorMessage.value)
  }
}

// UI Test with Espresso
@RunWith(AndroidJUnit4::class)
class LoginActivityTest {
  @get:Rule
  val activityRule = ActivityScenarioRule(LoginActivity::class.java)

  @Test
  fun testLoginWithValidCredentials() {
    onView(withId(R.id.emailInput))
      .perform(typeText("user@example.com"))

    onView(withId(R.id.passwordInput))
      .perform(typeText("password123"))

    onView(withId(R.id.loginButton))
      .perform(click())

    onView(withText("Home"))
      .check(matches(isDisplayed()))
  }

  @Test
  fun testLoginWithInvalidCredentials() {
    onView(withId(R.id.emailInput))
      .perform(typeText("invalid@example.com"))

    onView(withId(R.id.passwordInput))
      .perform(typeText("wrongpassword"))

    onView(withId(R.id.loginButton))
      .perform(click())

    onView(withText(containsString("Invalid credentials")))
      .check(matches(isDisplayed()))
  }

  @Test
  fun testNavigationBetweenTabs() {
    onView(withId(R.id.profileTab)).perform(click())
    onView(withText("Profile")).check(matches(isDisplayed()))

    onView(withId(R.id.homeTab)).perform(click())
    onView(withText("Home")).check(matches(isDisplayed()))
  }
}

4. Performance Testing

import XCTest

class PerformanceTests: XCTestCase {
  func testListRenderingPerformance() {
    let viewModel = ItemsViewModel()
    viewModel.items = (0..<1000).map { i in
      Item(id: UUID(), title: "Item \(i)", price: Double(i))
    }

    measure {
      _ = viewModel.items.filter { $0.price > 50 }
    }
  }

  func testNetworkResponseTime() {
    let networkService = NetworkService()

    measure {
      let expectation = XCTestExpectation(description: "Fetch user")

      Task {
        do {
          _ = try await networkService.fetch(User.self, from: "/users/test")
          expectation.fulfill()
        } catch {
          XCTFail("Network request failed")
        }
      }

      wait(for: [expectation], timeout: 10)
    }
  }
}

Best Practices

✅ DO

  • Write tests for business logic first
  • Use dependency injection for testability
  • Mock external API calls
  • Test both success and failure paths
  • Automate UI testing for critical flows
  • Run tests on real devices
  • Measure performance on target devices
  • Keep tests isolated and independent
  • Use meaningful test names
  • Maintain >80% code coverage

❌ DON'T

  • Skip testing UI-critical flows
  • Use hardcoded test data
  • Ignore performance regressions
  • Test implementation details
  • Make tests flaky or unreliable
  • Skip testing on actual devices
  • Ignore accessibility testing
  • Create interdependent tests
  • Test without mocking APIs
  • Deploy untested code

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/mobile-app-testing-mm5t89u5/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/mobile-app-testing-mm5t89u5' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/mobile-app-testing-mm5t89u5/download' --output '.skill-downloads/mobile-app-testing-mm5t89u5/SKILL.md.part' && mv '.skill-downloads/mobile-app-testing-mm5t89u5/SKILL.md.part' '.skill-downloads/mobile-app-testing-mm5t89u5/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/mobile-app-testing-mm5t89u5/SKILL.md' && test -s '.skill-downloads/mobile-app-testing-mm5t89u5/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/mobile-app-testing' && cp -R '.skill-downloads/mobile-app-testing-mm5t89u5' '.claude/skills/mobile-app-testing'

Cursor
test -f '.skill-downloads/mobile-app-testing-mm5t89u5/SKILL.md' && test -s '.skill-downloads/mobile-app-testing-mm5t89u5/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/mobile-app-testing' && cp -R '.skill-downloads/mobile-app-testing-mm5t89u5' '.cursor/skills/mobile-app-testing'

Codex
test -f '.skill-downloads/mobile-app-testing-mm5t89u5/SKILL.md' && test -s '.skill-downloads/mobile-app-testing-mm5t89u5/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/mobile-app-testing' && cp -R '.skill-downloads/mobile-app-testing-mm5t89u5' '.agents/skills/mobile-app-testing'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/mobile-app-testing-mm5t89u5'

openskills read 'mobile-app-testing-mm5t89u5'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/mobile-app-testing-mm5t89u5/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills