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 的示例测试代码片段,以及最佳实践与应避免的做法。它仅为说明性参考,不生成文件或脚本。
适用场景
适用于搭建或统一移动端测试基础设施、编写单元测试、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 从公开仓库中收录这些内容。

举报或申请下架