mcpField
M
mobile-app-testing

mobile-app-testing

github.com/secondskyテスト・品質240472 回インストール5 週間前に更新
リポジトリ

mobile-app-testing について

React Native、iOS、Android を扱うチーム向けのモバイルアプリテストスキルです。テストピラミッドを示し、ユニット、統合、エンドツーエンドテストの例を紹介します。

主な機能

  1. 01テストピラミッドのガイド
  2. 02React Native の Jest と Detox の例
  3. 03iOS XCTest の例
  4. 04Android Espresso の例
  5. 05カバレッジと失敗ケースのテスト指針

活用シーン

  1. 01ユニット、統合、エンドツーエンドの範囲を計画
  2. 02モバイルアプリのログインなど重要なフローをテスト
  3. 03ビジネスロジックとエラー処理を確認

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/secondsky/claude-skills --skill mobile-app-testing

インストール後、Claude Code で/mobile-app-testingを入力して読み込まれたか確認します。

詳細

モバイルアプリのテスト

モバイルアプリに包括的なテスト戦略を導入します。

テストピラミッド

レベルツールカバレッジ
単体Jest、XCTest、JUnit70%
統合Detox、Espresso20%
E2EAppium、Detox10%

React Native(Jest + Detox)

// Unit test
describe('CartService', () => {
  it('calculates total correctly', () => {
    const cart = new CartService();
    cart.addItem({ price: 10, quantity: 2 });
    expect(cart.getTotal()).toBe(20);
  });
});

// E2E test (Detox)
describe('Login flow', () => {
  beforeEach(async () => {
    await device.reloadReactNative();
  });

  it('should login successfully', async () => {
    await element(by.id('email-input')).typeText('[email protected]');
    await element(by.id('password-input')).typeText('password123');
    await element(by.id('login-button')).tap();
    await expect(element(by.id('dashboard'))).toBeVisible();
  });
});

iOS(XCTest)

func testLoginSuccess() {
    let app = XCUIApplication()
    app.launch()

    app.textFields["email"].tap()
    app.textFields["email"].typeText("[email protected]")
    app.secureTextFields["password"].typeText("password123")
    app.buttons["Login"].tap()

    XCTAssertTrue(app.staticTexts["Welcome"].exists)
}

Android(Espresso)

@Test
fun loginSuccess() {
    onView(withId(R.id.email)).perform(typeText("[email protected]"))
    onView(withId(R.id.password)).perform(typeText("password123"))
    onView(withId(R.id.loginButton)).perform(click())
    onView(withId(R.id.dashboard)).check(matches(isDisplayed()))
}

ベストプラクティス

  • まずビジネスロジックをテストします(単体テスト)。
  • 外部依存関係をモックします。
  • 成功パスと失敗パスの両方をテストします。
  • 重要なユーザーフローを自動化します。
  • コードカバレッジを80%超に維持します。
  • 定期的に実機でテストします。

避けるべきこと

  • 実装の詳細をテストすること
  • テストデータをハードコードすること
  • 相互依存するテスト
  • エラーケースのテストを省略すること

コメント