Skip to content

Commit 80c7a76

Browse files
add build files (#75)
* add build files * Fix CI
1 parent fc9740e commit 80c7a76

File tree

8 files changed

+232
-92
lines changed

8 files changed

+232
-92
lines changed

.azure-template/bootstrap.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
steps:
2+
- task: NodeTool@0
3+
inputs:
4+
versionSpec: "$(NODE_VERSION)"
5+
- script: |
6+
npm config delete prefix
7+
npm config set prefix $NVM_DIR/versions/node/`node --version`
8+
node --version
9+
npm install -g appium@next

__tests__/e2e/plugin.spec.js

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { remote } from 'webdriverio';
2-
import { pluginE2EHarness } from '@appium/plugin-test-support';
3-
import path from 'path';
2+
import { resolve } from 'path';
43
var chai = require('chai'),
54
chaiAsPromised = require('chai-as-promised');
65

@@ -9,18 +8,12 @@ chai.use(chaiAsPromised);
98
should = chai.should();
109
let expect = chai.expect;
1110

12-
const APPIUM_HOST = 'localhost';
13-
const FAKE_ARGS = { timeout: 10000, intervalBetweenAttempts: 1000 };
14-
const FAKE_PLUGIN_ARGS = { 'element-wait': FAKE_ARGS };
11+
const APPIUM_HOST = '127.0.0.1';
12+
const DEFAULT_TIMEOUT_VALUE = { timeout: 10000, intervalBetweenAttempts: 500 };
1513

16-
const THIS_PLUGIN_DIR = path.join(__dirname, '..', '..');
17-
const APPIUM_HOME = path.join(THIS_PLUGIN_DIR, 'local_appium_home');
18-
const FAKE_DRIVER_DIR =
19-
process.env.PLATFORM === 'android' ? 'appium-uiautomator2-driver' : 'appium-xcuitest-driver';
20-
const TEST_HOST = 'localhost';
21-
const TEST_PORT = 4723;
14+
const androidApp = resolve('./build/VodQA.apk');
15+
const iosApp = resolve('./build/vodqa.zip');
2216

23-
let server;
2417
const WDIO_PARAMS = {
2518
connectionRetryCount: 220000,
2619
hostname: APPIUM_HOST,
@@ -31,37 +24,22 @@ const androidCaps = {
3124
platformName: 'Android',
3225
'appium:uiautomator2ServerInstallTimeout': '120000',
3326
'appium:automationName': 'UIAutomator2',
34-
'appium:app':
35-
'https://github.com/AppiumTestDistribution/appium-demo/blob/main/VodQA.apk?raw=true',
27+
'appium:app': androidApp,
3628
};
3729

3830
const iOSCaps = {
3931
platformName: 'iOS',
4032
'appium:automationName': 'XCUITest',
41-
'appium:deviceName': 'iPhone 14 Pro',
33+
'appium:deviceName': 'iPhone 12',
4234
'appium:platformVersion': '16.2',
43-
'appium:app':
44-
'https://github.com/AppiumTestDistribution/appium-demo/blob/main/vodqa.zip?raw=true',
35+
'appium:app': iosApp,
36+
'appium:usePrebuiltWDA': true,
37+
'appium:wdaLaunchTimeout': 120000
4538
};
4639

4740
describe('Set Timeout', () => {
4841
describe('with CLI args', () => {
4942
let driver;
50-
pluginE2EHarness({
51-
before,
52-
after,
53-
server,
54-
serverArgs: { basePath: '/wd/hub', plugin: FAKE_PLUGIN_ARGS },
55-
port: TEST_PORT,
56-
host: TEST_HOST,
57-
appiumHome: APPIUM_HOME,
58-
driverName: process.env.PLATFORM === 'android' ? 'uiautomator2' : 'xcuitest',
59-
driverSource: 'npm',
60-
driverSpec: FAKE_DRIVER_DIR,
61-
pluginName: 'element-wait',
62-
pluginSource: 'local',
63-
pluginSpec: '.',
64-
});
6543
beforeEach(async () => {
6644
driver = await remote({
6745
...WDIO_PARAMS,
@@ -70,7 +48,9 @@ describe('Set Timeout', () => {
7048
});
7149
it('Should be able to set and get waitPlugin timeout', async () => {
7250
await driver.$('~login').click();
73-
expect(await driver.executeScript('plugin: getWaitTimeout', [])).to.deep.include(FAKE_ARGS);
51+
expect(await driver.executeScript('plugin: getWaitTimeout', [])).to.deep.include(
52+
DEFAULT_TIMEOUT_VALUE
53+
);
7454
await driver.executeScript('plugin: setWaitTimeout', [
7555
{
7656
timeout: 1111,
@@ -85,7 +65,6 @@ describe('Set Timeout', () => {
8565

8666
afterEach(async () => {
8767
await driver.deleteSession();
88-
if (server) await server.close();
8968
});
9069
});
9170
});

azure-pipelines.yml

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,67 @@
1+
# Gradle
2+
# Build your Java project and run tests with Gradle using a Gradle wrapper script.
3+
# Add steps that analyze code, save build artifacts, deploy, and more:
4+
# https://docs.microsoft.com/azure/devops/pipelines/languages/java
15
trigger:
26
- main
37

8+
variables:
9+
ANDROID_EMU_NAME: test
10+
ANDROID_EMU_ABI: x86
11+
ANDROID_EMU_TARGET: android-28
12+
ANDROID_EMU_TAG: default
13+
XCODE_VERSION: 14.2
14+
IOS_PLATFORM_VERSION: 16.2
15+
IOS_DEVICE_NAME: iPhone 12
16+
NODE_VERSION: 18.x
17+
JDK_VERSION: 1.8
18+
419
jobs:
5-
- job: UnitTest
20+
- job: Android_E2E_Tests
621
pool:
722
vmImage: 'macOS-latest'
8-
923
steps:
10-
11-
inputs:
12-
versionSpec: '16.x'
13-
24+
- template: .azure-template/bootstrap.yml
25+
- script: $NVM_DIR/versions/node/`node --version`/bin/appium driver install uiautomator2
26+
displayName: Install UIA2 driver
1427
- script: |
15-
npm ci
16-
npm test
17-
displayName: 'npm test'
18-
19-
- job: ANDROID
20-
pool:
21-
vmImage: 'macOS-latest'
22-
23-
steps:
24-
25-
inputs:
26-
versionSpec: '16.x'
27-
28+
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;$(ANDROID_EMU_TARGET);$(ANDROID_EMU_TAG);$(ANDROID_EMU_ABI)'
29+
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n "$(ANDROID_EMU_NAME)" -k 'system-images;$(ANDROID_EMU_TARGET);$(ANDROID_EMU_TAG);$(ANDROID_EMU_ABI)' --force
30+
echo $ANDROID_HOME/emulator/emulator -list-avds
31+
32+
echo "Starting emulator"
33+
nohup $ANDROID_HOME/emulator/emulator -avd "$(ANDROID_EMU_NAME)" -no-snapshot -delay-adb > /dev/null 2>&1 &
34+
$ANDROID_HOME/platform-tools/adb wait-for-device
35+
$ANDROID_HOME/platform-tools/adb devices -l
36+
echo "Emulator started"
37+
displayName: Emulator configuration
2838
- script: |
2939
npm ci
30-
displayName: 'npm install'
31-
32-
- bash: |
33-
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-27;google_apis;x86'
34-
displayName: "install Android image"
35-
- script: |
36-
$ANDROID_HOME/emulator/emulator -list-avds
37-
echo '---'
38-
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n test_android_emulator -k 'system-images;android-27;google_apis;x86' --force
39-
echo '---'
40-
$ANDROID_HOME/emulator/emulator -list-avds
41-
displayName: "create AVD"
42-
- script: |
43-
$ANDROID_HOME/platform-tools/adb devices
44-
echo '---'
45-
nohup $ANDROID_HOME/emulator/emulator -avd test_android_emulator -no-snapshot > /dev/null 2>&1 & $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
46-
echo '---'
47-
$ANDROID_HOME/platform-tools/adb devices
48-
displayName: "start Android emulator"
49-
- script: |
50-
PLATFORM='android' npm run test-e2e
51-
displayName: "Android Integration Test"
52-
- job: iOS
40+
$NVM_DIR/versions/node/$(node --version)/bin/appium plugin install --source=local .
41+
nohup $NVM_DIR/versions/node/$(node --version)/bin/appium server -ka 800 --use-plugins=element-wait -pa /wd/hub &
42+
sleep 10
43+
PLATFORM=android npm run test-e2e
44+
displayName: Android E2E Test
45+
- job: iOS_E2E_Tests
5346
pool:
5447
vmImage: 'macOS-latest'
55-
48+
# timeoutInMinutes: '90'
5649
steps:
57-
58-
inputs:
59-
versionSpec: '16.x'
60-
61-
- script: |
62-
npm ci
63-
displayName: 'npm install'
64-
50+
- template: .azure-template/bootstrap.yml
6551
- script: |
52+
sudo xcode-select -s /Applications/Xcode_$(XCODE_VERSION).app/Contents/Developer
6653
xcrun simctl list
67-
PLATFORM='ios' npm run test-e2e
68-
displayName: "iOS Integration Test"
54+
target_sim_id=$(xcrun simctl list devices available | grep "$IOS_DEVICE_NAME (" | cut -d "(" -f2 | cut -d ")" -f1)
55+
open -Fn "/Applications/Xcode_$(XCODE_VERSION).app/Contents/Developer/Applications/Simulator.app"
56+
xcrun simctl bootstatus $target_sim_id -b
57+
displayName: Prepare iOS Simulator
58+
- script: $NVM_DIR/versions/node/$(node --version)/bin/appium driver install xcuitest
59+
displayName: Install XCUITest driver
60+
- script: $NVM_DIR/versions/node/$(node --version)/bin/appium driver run xcuitest build-wda
61+
displayName: Prebuild XCUITest driver
62+
- script: |
63+
npm ci
64+
nohup $NVM_DIR/versions/node/$(node --version)/bin/appium server -ka 800 --use-plugins=element-wait -pa /wd/hub &
65+
sleep 10
66+
PLATFORM=ios npm run test-e2e
67+
displayName: iOS E2E Test

build/VodQA.apk

24 MB
Binary file not shown.

build/vodqa.zip

2.91 MB
Binary file not shown.

0 commit comments

Comments
 (0)