Mobile App Testing

作者 secondsky88378361314fMIT227 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫10 天前更新

Mobile app testing with unit tests, UI automation, performance testing. Use for test infrastructure, E2E tests, testing standards, or encountering test framework setup, device farms, flaky tests, platform-specific test errors.

AI 產生的概覽

指導如何實作行動應用程式測試策略,涵蓋單元、整合與端對端測試層級。

功能
提供行動應用程式的測試金字塔參考,將單元、整合與端對端層級對應到 Jest、XCTest、JUnit、Detox、Espresso、Appium 等工具。內含 React Native、iOS 與 Android 的範例測試程式碼片段,以及最佳實務與應避免的做法。它僅為說明性參考,不會產生檔案或指令碼。
適用情境
適用於建立或統一 mobile 測試基礎架構、撰寫單元測試、UI 自動化或端對端測試,或排查測試框架設定、裝置農場、不穩定測試及平台相關測試錯誤時。
執行需求
不需要任何工具、套件或憑證;僅為說明性內容,不附帶指令碼。範例程式碼片段涉及 Jest、Detox、XCTest、Espresso 與 Appium,需由使用者在自己的專案中提供。

Mobile App Testing

Implement comprehensive testing strategies for mobile applications.

Testing Pyramid

LevelToolsCoverage
UnitJest, XCTest, JUnit70%
IntegrationDetox, Espresso20%
E2EAppium, Detox10%

React Native (Jest + Detox)

javascript
// Unit testdescribe('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)

swift
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)

kotlin
@Testfun 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()))}

Best Practices

  • Test business logic first (unit tests)
  • Mock external dependencies
  • Test both success and failure paths
  • Automate critical user flows
  • Maintain >80% code coverage
  • Test on real devices periodically

Avoid

  • Testing implementation details
  • Hardcoded test data
  • Interdependent tests
  • Skipping error case testing

來源與署名

來源:secondsky/claude-skills位於plugins/mobile-app-testing/skills/mobile-app-testing提交8837836

授權條款: MIT

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架