Skip to content

Commit edd968d

Browse files
authored
ci: add functional-test for android (#993)
* ci: add functional-test * modify the order * run one line * skip failed tests on CI for now * fix a couple of errors * add espresso driver and relaxed-security * add wait for * format * skip some tests * skip tests more because of slow CI * add log * modify a bit * keep old logs * add enforceAppInstall to run espresso properly * add skip
1 parent a38b863 commit edd968d

File tree

14 files changed

+296
-27
lines changed

14 files changed

+296
-27
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Functional Tests (Android)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 'release/**'
8+
pull_request:
9+
branches:
10+
- main
11+
- 'release/**'
12+
workflow_dispatch:
13+
14+
jobs:
15+
android-tests:
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
api-level: [30]
22+
target: [google_apis]
23+
24+
env:
25+
BUILD_CONFIGURATION: 'Release'
26+
CI: true
27+
APPIUM_LOG_PATH: '${{ github.workspace }}/appium.log'
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Setup .NET
34+
uses: actions/setup-dotnet@v4
35+
with:
36+
dotnet-version: '8.0.x'
37+
38+
- name: Enable KVM
39+
run: |
40+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
41+
sudo udevadm control --reload-rules
42+
sudo udevadm trigger --name-match=kvm
43+
44+
- name: Setup Java
45+
uses: actions/setup-java@v5
46+
with:
47+
distribution: 'temurin'
48+
java-version: '17'
49+
50+
- name: Setup Android SDK
51+
uses: android-actions/setup-android@v3
52+
53+
- name: AVD cache
54+
uses: actions/cache@v4
55+
id: avd-cache
56+
with:
57+
path: |
58+
~/.android/avd/*
59+
~/.android/adb*
60+
key: avd-${{ matrix.api-level }}
61+
62+
- name: Create AVD and generate snapshot for caching
63+
if: steps.avd-cache.outputs.cache-hit != 'true'
64+
uses: reactivecircus/android-emulator-runner@v2
65+
with:
66+
api-level: ${{ matrix.api-level }}
67+
target: ${{ matrix.target }}
68+
arch: x86_64
69+
force-avd-creation: false
70+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
71+
disable-animations: false
72+
script: echo "Generated AVD snapshot for caching."
73+
74+
- name: Setup Node.js
75+
uses: actions/setup-node@v4
76+
with:
77+
node-version: '20'
78+
79+
- name: Install Appium
80+
run: npm install -g appium
81+
82+
- name: Install UiAutomator2 driver
83+
run: appium driver install uiautomator2
84+
85+
- name: Install Espresso driver
86+
run: appium driver install espresso
87+
88+
- name: Restore dependencies
89+
run: dotnet restore Appium.Net.sln
90+
91+
- name: Build solution
92+
run: dotnet build Appium.Net.sln --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore
93+
94+
- name: Create test environment file
95+
run: |
96+
cat > ./test/integration/env.json << 'EOF'
97+
{
98+
"DEV": "false",
99+
"isRemoteAppiumServer": "false",
100+
"remoteAppiumServerUri": "http://localhost:4723"
101+
}
102+
EOF
103+
104+
- name: Run Android functional tests
105+
uses: reactivecircus/android-emulator-runner@v2
106+
with:
107+
api-level: ${{ matrix.api-level }}
108+
target: ${{ matrix.target }}
109+
arch: x86_64
110+
force-avd-creation: false
111+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
112+
disable-animations: true
113+
script: |
114+
adb devices
115+
dotnet test --configuration ${{ env.BUILD_CONFIGURATION }} --no-build --framework net8.0 --filter "FullyQualifiedName~Android" --logger "trx;LogFileName=android-test-results.trx" --logger "console;verbosity=detailed" ./test/integration/Appium.Net.Integration.Tests.csproj
116+
117+
- name: Publish test results
118+
uses: dorny/test-reporter@v1
119+
if: always()
120+
with:
121+
name: Android Test Results (API ${{ matrix.api-level }})
122+
path: '**/android-test-results.trx'
123+
reporter: dotnet-trx
124+
125+
- name: Save server output
126+
if: ${{ always() }}
127+
uses: actions/upload-artifact@master
128+
with:
129+
name: appium-${{ matrix.api-level }}.log
130+
path: |
131+
appium*.log

test/integration/Android/ActionsChainsTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ public void ScrollActionTestCase()
189189
[Test]
190190
public void ScrollUsingAddActionsTestCase()
191191
{
192+
if (Env.IsCiEnvironment())
193+
{
194+
Assert.Ignore("Skipping ScrollUsingAddActionsTestCase test in CI environment");
195+
}
192196
AppiumElement ViewsElem = _driver.FindElement(MobileBy.AccessibilityId("Views"));
193197

194198
ActionBuilder actionBuilder = new ActionBuilder();

test/integration/Android/BiDiTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public void BeforeAll()
2424
[Test]
2525
public async Task RunBiDiScript()
2626
{
27+
if (Env.IsCiEnvironment())
28+
{
29+
Assert.Ignore("Skipping BiDi test in CI environment");
30+
}
2731
_bidi = await _driver.AsBiDiAsync();
2832
await _bidi.StatusAsync();
2933
}

test/integration/Android/Device/AuthenticationTest.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class AuthenticationTest
1313
[OneTimeSetUp]
1414
public void BeforeAll()
1515
{
16-
16+
1717
var capabilities = Caps.GetAndroidUIAutomatorCaps(Apps.Get(appID));
1818
capabilities.AddAdditionalAppiumOption(MobileCapabilityType.FullReset, true);
1919
var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri;
@@ -37,6 +37,10 @@ public void OneTimeTearDown()
3737
[Test]
3838
public void TestSendFingerprint()
3939
{
40+
if (Env.IsCiEnvironment())
41+
{
42+
Assert.Ignore("Skipping fingerprint test in CI - biometric may not be available on emulator");
43+
}
4044
// There's no way to verify sending fingerprint had an effect,
4145
// so just test that it's successfully called without an exception
4246
_driver.FingerPrint(1);

test/integration/Android/Device/PerformanceDataTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,21 @@ public void TearDown()
3232
[Test]
3333
public void GetPerformanceDataTypesTest()
3434
{
35+
if (Env.IsCiEnvironment())
36+
{
37+
Assert.Ignore("Skipping performance data test in CI - may not be supported on emulator");
38+
}
3539
var androidDriver = _driver as AndroidDriver;
3640
Assert.That(androidDriver.GetPerformanceDataTypes(), Is.Not.Null);
3741
}
3842

3943
[Test]
4044
public void GetPerformanceDataTest()
4145
{
46+
if (Env.IsCiEnvironment())
47+
{
48+
Assert.Ignore("Skipping performance data test in CI - may not be supported on emulator");
49+
}
4250
var androidDriver = _driver as AndroidDriver;
4351
var packageName = androidDriver?.CurrentPackage;
4452

0 commit comments

Comments
 (0)