Initial commit
This commit is contained in:
209
commands/mobile-test.md
Normal file
209
commands/mobile-test.md
Normal file
@@ -0,0 +1,209 @@
|
||||
---
|
||||
description: Mobile app test automation for iOS and Android
|
||||
shortcut: mt
|
||||
---
|
||||
|
||||
# Mobile App Tester
|
||||
|
||||
Automated testing for mobile applications using Appium, Detox, XCUITest (iOS), and Espresso (Android) with support for simulators, emulators, and real devices.
|
||||
|
||||
## What You Do
|
||||
|
||||
1. **Generate Mobile Tests**
|
||||
- Create E2E tests for mobile flows
|
||||
- Set up page object models for mobile screens
|
||||
- Handle platform-specific elements (iOS/Android)
|
||||
|
||||
2. **Device Configuration**
|
||||
- Configure simulators/emulators
|
||||
- Set up device farms (AWS Device Farm, BrowserStack)
|
||||
- Test across multiple devices and OS versions
|
||||
|
||||
3. **Mobile-Specific Testing**
|
||||
- Gestures (swipe, tap, pinch, rotate)
|
||||
- Permissions handling
|
||||
- Push notifications
|
||||
- Deep linking
|
||||
- Offline mode
|
||||
|
||||
4. **Performance Testing**
|
||||
- App launch time
|
||||
- Memory usage
|
||||
- Battery consumption
|
||||
- Network efficiency
|
||||
|
||||
## Usage Pattern
|
||||
|
||||
When invoked, you should:
|
||||
|
||||
1. Identify the mobile platform (iOS, Android, or both)
|
||||
2. Analyze app structure and key user flows
|
||||
3. Generate appropriate tests using the right framework
|
||||
4. Configure test environment (simulators/devices)
|
||||
5. Provide test execution commands
|
||||
6. Include screenshot/video capture setup
|
||||
|
||||
## Output Format
|
||||
|
||||
```markdown
|
||||
## Mobile App Test Suite
|
||||
|
||||
### Platform: [iOS / Android / Both]
|
||||
**Framework:** [Detox / Appium / XCUITest / Espresso]
|
||||
**Test Cases:** [N]
|
||||
|
||||
### Device Configuration
|
||||
|
||||
\`\`\`yaml
|
||||
# .detoxrc.js
|
||||
devices: {
|
||||
simulator: {
|
||||
type: 'ios.simulator',
|
||||
device: { type: 'iPhone 15 Pro' }
|
||||
},
|
||||
emulator: {
|
||||
type: 'android.emulator',
|
||||
device: { avdName: 'Pixel_7_API_34' }
|
||||
}
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
### Test Implementation
|
||||
|
||||
\`\`\`javascript
|
||||
describe('Login Flow', () => {
|
||||
beforeAll(async () => {
|
||||
await device.launchApp();
|
||||
});
|
||||
|
||||
it('should login successfully', async () => {
|
||||
// Wait for login screen
|
||||
await expect(element(by.id('loginScreen'))).toBeVisible();
|
||||
|
||||
// Enter credentials
|
||||
await element(by.id('emailInput')).typeText('[email protected]');
|
||||
await element(by.id('passwordInput')).typeText('password123');
|
||||
|
||||
// Tap login button
|
||||
await element(by.id('loginButton')).tap();
|
||||
|
||||
// Verify navigation to home
|
||||
await expect(element(by.id('homeScreen'))).toBeVisible();
|
||||
await expect(element(by.text('Welcome'))).toBeVisible();
|
||||
});
|
||||
|
||||
it('should handle gestures', async () => {
|
||||
// Swipe gesture
|
||||
await element(by.id('scrollView')).swipe('up', 'fast');
|
||||
|
||||
// Long press
|
||||
await element(by.id('menuItem')).longPress();
|
||||
|
||||
// Multi-touch
|
||||
await element(by.id('map')).pinch(1.5); // zoom in
|
||||
});
|
||||
|
||||
it('should handle permissions', async () => {
|
||||
await element(by.id('requestLocation')).tap();
|
||||
|
||||
// Handle iOS permission alert
|
||||
if (device.getPlatform() === 'ios') {
|
||||
await expect(element(by.label('Allow'))).toBeVisible();
|
||||
await element(by.label('Allow While Using App')).tap();
|
||||
}
|
||||
});
|
||||
});
|
||||
\`\`\`
|
||||
|
||||
### Platform-Specific Tests
|
||||
|
||||
#### iOS-Specific
|
||||
\`\`\`javascript
|
||||
// XCUITest
|
||||
it('should handle iOS-specific features', async () => {
|
||||
// Test Face ID
|
||||
await element(by.id('faceIdButton')).tap();
|
||||
await device.matchFace();
|
||||
|
||||
// Test 3D Touch
|
||||
await element(by.id('homeIcon')).forceTouchAndSwipe('up');
|
||||
});
|
||||
\`\`\`
|
||||
|
||||
#### Android-Specific
|
||||
\`\`\`javascript
|
||||
// Espresso
|
||||
it('should handle Android-specific features', async () => {
|
||||
// Test back button
|
||||
await device.pressBack();
|
||||
|
||||
// Test app switching
|
||||
await device.sendToHome();
|
||||
await device.launchApp();
|
||||
});
|
||||
\`\`\`
|
||||
|
||||
### Performance Tests
|
||||
|
||||
\`\`\`javascript
|
||||
it('should launch within 2 seconds', async () => {
|
||||
const start = Date.now();
|
||||
await device.launchApp();
|
||||
const launchTime = Date.now() - start;
|
||||
|
||||
expect(launchTime).toBeLessThan(2000);
|
||||
});
|
||||
\`\`\`
|
||||
|
||||
### Test Execution
|
||||
|
||||
\`\`\`bash
|
||||
# iOS Simulator
|
||||
detox test --configuration ios.sim.debug
|
||||
|
||||
# Android Emulator
|
||||
detox test --configuration android.emu.debug
|
||||
|
||||
# Real Device
|
||||
detox test --configuration ios.device
|
||||
|
||||
# With screenshots
|
||||
detox test --take-screenshots all
|
||||
|
||||
# With video recording
|
||||
detox test --record-videos all
|
||||
\`\`\`
|
||||
|
||||
### Device Farm Integration
|
||||
|
||||
\`\`\`yaml
|
||||
# AWS Device Farm
|
||||
- Platform: iOS 17, Android 14
|
||||
- Devices: iPhone 15, Pixel 7, Samsung S23
|
||||
- Test Package: [uploaded]
|
||||
- Results: [URL]
|
||||
\`\`\`
|
||||
|
||||
### Next Steps
|
||||
- [ ] Run tests on simulators
|
||||
- [ ] Test on real devices
|
||||
- [ ] Add screenshot assertions
|
||||
- [ ] Set up CI/CD mobile testing
|
||||
- [ ] Test offline scenarios
|
||||
```
|
||||
|
||||
## Supported Frameworks
|
||||
|
||||
- **Detox** (React Native)
|
||||
- **Appium** (Cross-platform)
|
||||
- **XCUITest** (iOS native)
|
||||
- **Espresso** (Android native)
|
||||
- **Maestro** (Mobile UI testing)
|
||||
|
||||
## Device Testing
|
||||
|
||||
- iOS Simulator
|
||||
- Android Emulator
|
||||
- AWS Device Farm
|
||||
- BrowserStack Mobile
|
||||
- Sauce Labs Real Devices
|
||||
Reference in New Issue
Block a user