-
Notifications
You must be signed in to change notification settings - Fork 45
/
test_spec.yaml
138 lines (121 loc) · 5.47 KB
/
test_spec.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
version: 0.1
# Phases are collection of commands that get executed on Device Farm.
phases:
# The install phase includes commands that install dependencies that your tests use.
# Default dependencies for testing frameworks supported on Device Farm are already installed.
install:
commands:
# By default, Appium server version used is 1.7.2.
# You can switch to an alternate supported version from 1.6.5, 1.7.1, 1.7.2, 1.8.0 or 1.8.1 by using a command like "avm 1.7.1"
# OR
# To install a newer version of Appium use the following commands:
# - export APPIUM_VERSION=1.8.1
# - avm $APPIUM_VERSION
# - ln -s /usr/local/avm/versions/$APPIUM_VERSION/node_modules/.bin/appium /usr/local/avm/versions/$APPIUM_VERSION/node_modules/appium/bin/appium.js
# enter flutter app directory in Appium bundle
- cd flutter_app
- ls -la
# check for bash
- bash --version
# env
#- env
#- whoami
#- groups
- echo "DEVICEFARM_APP_PATH=$DEVICEFARM_APP_PATH"
# install flutter
- echo "Install flutter"
- FLUTTER_VERSION='v1.12.13+hotfix.5-stable'
- >-
if [ $DEVICEFARM_DEVICE_PLATFORM_NAME = "Android" ];
then
# Install Flutter
curl https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_$FLUTTER_VERSION.tar.xz -o flutter_linux.tar.xz
tar xf flutter_linux.tar.xz
fi
if [ $DEVICEFARM_DEVICE_PLATFORM_NAME = "iOS" ];
then
# Install Flutter
curl https://storage.googleapis.com/flutter_infra/releases/stable/macos/flutter_macos_$FLUTTER_VERSION.zip -o flutter_macos.zip
unzip -qq flutter_macos.zip
fi
- mv flutter $HOME/flutter
- export PATH=$PATH:$HOME/flutter/bin:$HOME/flutter/bin/cache/dart-sdk/bin
- export PATH="$PATH":"$HOME/.pub-cache/bin"
- flutter doctor -v
# The pre-test phase includes commands that setup your test environment.
pre_test:
commands:
# We recommend starting appium server process in the background using the command below.
# Appium server log will go to $DEVICEFARM_LOG_DIR directory.
# The environment variables below will be auto-populated during run time.
# The test phase includes commands that run your test suite execution.
test:
commands:
# Report status of each command exit code.
# Use last failing command exit code as test phase exit code
# or
# if no command failed, exit test phase normally.
# (this is required because test phase does not track a failed command correctly.
- TEST_PHASE_STATUS=0 # success
- >-
track_test_phase_status() {
local command_exit_code=$?
if [ "$command_exit_code" != "0" ]; then
echo "Most recent command failed with error code: $command_exit_code"
TEST_PHASE_STATUS=$command_exit_code
fi
}
set_test_phase_exit_code() {
return $TEST_PHASE_STATUS
}
# Your test package is downloaded in $DEVICEFARM_TEST_PACKAGE_PATH so we first change directory to that path.
# We already setup python virtual environment on $DEVICEFARM_TEST_PACKAGE_PATH
# and installed required libraries. You can run your test under $DEVICEFARM_TEST_PACKAGE_PATH
- echo "Navigate to test package directory"
- cd $DEVICEFARM_TEST_PACKAGE_PATH
- echo "Start Flutter integration test"
# By default, the following command is used by Device Farm to run your Appium Python test.
# The goal is to run all your tests files in the test package.
# Alternatively, You may specify your customized command.
# Note: For most use cases, the default command works fine.
# Please refer "https://docs.pytest.org/en/latest/usage.html" for more options on running pytests from command line.
# - bin/py.test tests/ --junit-xml $DEVICEFARM_LOG_DIR/junitreport.xml
- cd flutter_app
- rm .packages # todo: remove from bundle
- MAIN=test_driver/main.dart
- TESTS='test_driver/main_test.dart'
- >-
if [ $DEVICEFARM_DEVICE_PLATFORM_NAME = "Android" ];
then
./script/test_android.sh --run-tests "$TESTS"
track_test_phase_status
fi
if [ $DEVICEFARM_DEVICE_PLATFORM_NAME = "iOS" ];
then
./script/test_ios.sh --unpack $DEVICEFARM_APP_PATH
track_test_phase_status
./script/test_ios.sh --dummy-symbols build_to_os.txt
track_test_phase_status
./script/test_ios.sh --run-tests "$MAIN" "$TESTS"
track_test_phase_status
fi
# move any flutter crash logs to artifacts dir
- >-
for f in flutter_*.log; do
if [ -e "$f" ]; then
echo "Archiving $f to $DEVICEFARM_LOG_DIR"
mv $f $DEVICEFARM_LOG_DIR
fi
done
- ls -la $DEVICEFARM_LOG_DIR
- echo done.
- set_test_phase_exit_code
# The post test phase includes are commands that are run after your tests are executed.
post_test:
commands:
# The artifacts phase lets you specify the location where your tests logs, device logs will be stored.
# And also let you specify the location of your test logs and artifacts which you want to be collected by Device Farm.
# These logs and artifacts will be available through ListArtifacts API in Device Farm.
artifacts:
# By default, Device Farm will collect your artifacts from following directories
- $DEVICEFARM_LOG_DIR