Skip to content

Commit c3e8916

Browse files
chore: Include more tests into the pipeline (#1566)
1 parent e9a2cbc commit c3e8916

30 files changed

+755
-515
lines changed

azure-pipelines.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ variables:
1919

2020
jobs:
2121
- job: Android_E2E_Tests
22-
# timeoutInMinutes: '90'
2322
steps:
2423
- template: .azure-templates/bootstrap_steps.yml
2524
- script: |
@@ -61,3 +60,15 @@ jobs:
6160
publishJUnitResults: true
6261
tasks: 'build'
6362
options: 'xcuiTest -x checkstyleTest -x test'
63+
- job: Misc_Tests
64+
steps:
65+
- task: Gradle@2
66+
inputs:
67+
gradleWrapperFile: 'gradlew'
68+
gradleOptions: '-Xmx3072m'
69+
javaHomeOption: 'JDKVersion'
70+
jdkVersionOption: "$(JDK_VERSION)"
71+
jdkArchitectureOption: 'x64'
72+
publishJUnitResults: true
73+
tasks: 'build'
74+
options: 'miscTest -x checkstyleTest -x test -x signMavenJavaPublication'

build.gradle

+18-5
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,11 @@ task xcuiTest( type: Test ) {
189189
testLogging.showStandardStreams = true
190190
testLogging.exceptionFormat = 'full'
191191
filter {
192-
includeTestsMatching '*.appium.element.generation.ios.*'
193-
includeTestsMatching '*.appium.AppiumFluentWaitTest'
194192
includeTestsMatching 'io.appium.java_client.ios.*'
195193
includeTestsMatching '*.pagefactory_tests.XCUITModeTest'
196194
includeTestsMatching '*.pagefactory_tests.widget.tests.combined.*'
197195
includeTestsMatching '*.pagefactory_tests.widget.tests.ios.*'
198-
includeTestsMatching '*.StartingAppLocallyTest.startingIOSAppWithCapabilitiesAndServiceTest'
199-
includeTestsMatching '*.StartingAppLocallyTest.startingIOSAppWithCapabilitiesAndFlagsOnServerSideTest'
200-
exclude '**/UIAutomationTest.class'
196+
includeTestsMatching 'io.appium.java_client.service.local.StartingAppLocallyIosTest'
201197
exclude '**/IOSScreenRecordTest.class'
202198
exclude '**/ImagesComparisonTest.class'
203199
}
@@ -211,5 +207,22 @@ task uiAutomationTest( type: Test ) {
211207
includeTestsMatching 'io.appium.java_client.android.SettingTest'
212208
includeTestsMatching 'io.appium.java_client.android.ClipboardTest'
213209
includeTestsMatching '*.AndroidAppStringsTest'
210+
includeTestsMatching '*.pagefactory_tests.widget.tests.android.*'
211+
includeTestsMatching '*.pagefactory_tests.widget.tests.AndroidPageObjectTest'
212+
includeTestsMatching 'io.appium.java_client.service.local.StartingAppLocallyAndroidTest'
213+
includeTestsMatching 'io.appium.java_client.service.local.ServerBuilderTest'
214+
includeTestsMatching 'io.appium.java_client.service.local.ThreadSafetyTest'
215+
}
216+
}
217+
218+
task miscTest( type: Test ) {
219+
useJUnit()
220+
testLogging.showStandardStreams = true
221+
testLogging.exceptionFormat = 'full'
222+
filter {
223+
includeTestsMatching 'io.appium.java_client.touch.*'
224+
includeTestsMatching 'io.appium.java_client.events.*'
225+
includeTestsMatching 'io.appium.java_client.remote.*'
226+
includeTestsMatching 'io.appium.java_client.drivers.options.*'
214227
}
215228
}

src/main/java/io/appium/java_client/android/options/EspressoOptions.java

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
import io.appium.java_client.android.options.mjpeg.SupportsMjpegScreenshotUrlOption;
7676
import io.appium.java_client.android.options.mjpeg.SupportsMjpegServerPortOption;
7777
import io.appium.java_client.android.options.other.SupportsDisableSuppressAccessibilityServiceOption;
78+
import io.appium.java_client.android.options.server.SupportsEspressoBuildConfigOption;
7879
import io.appium.java_client.android.options.server.SupportsEspressoServerLaunchTimeoutOption;
7980
import io.appium.java_client.android.options.server.SupportsForceEspressoRebuildOption;
8081
import io.appium.java_client.android.options.server.SupportsShowGradleLogOption;
@@ -113,6 +114,7 @@ public class EspressoOptions extends BaseOptions<EspressoOptions> implements
113114
SupportsForceEspressoRebuildOption<EspressoOptions>,
114115
SupportsShowGradleLogOption<EspressoOptions>,
115116
SupportsOrientationOption<EspressoOptions>,
117+
SupportsEspressoBuildConfigOption<EspressoOptions>,
116118
// App options: https://github.com/appium/appium-uiautomator2-driver#app
117119
SupportsAppOption<EspressoOptions>,
118120
SupportsAppPackageOption<EspressoOptions>,

src/main/java/io/appium/java_client/android/options/app/ActivityOptions.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.appium.java_client.android.options.app;
1818

19+
import io.appium.java_client.internal.CapabilityHelpers;
1920
import io.appium.java_client.remote.options.BaseMapOptionData;
2021

2122
import java.util.Map;
@@ -48,6 +49,6 @@ public ActivityOptions withLaunchDisplayId(int id) {
4849
*/
4950
public Optional<Integer> getLaunchDisplayId() {
5051
Optional<Object> result = getOptionValue("launchDisplayId");
51-
return result.map((v) -> Integer.parseInt(String.valueOf(v)));
52+
return result.map(CapabilityHelpers::toInteger);
5253
}
5354
}

src/main/java/io/appium/java_client/android/options/server/EspressoBuildConfig.java

+20-73
Original file line numberDiff line numberDiff line change
@@ -16,57 +16,42 @@
1616

1717
package io.appium.java_client.android.options.server;
1818

19-
import com.google.gson.JsonArray;
20-
import com.google.gson.JsonObject;
21-
import com.google.gson.JsonParser;
19+
import io.appium.java_client.internal.CapabilityHelpers;
20+
import io.appium.java_client.remote.options.BaseMapOptionData;
2221

23-
import java.util.ArrayList;
22+
import java.util.HashMap;
2423
import java.util.List;
24+
import java.util.Map;
2525
import java.util.Optional;
2626

27-
public class EspressoBuildConfig {
27+
public class EspressoBuildConfig extends BaseMapOptionData<EspressoBuildConfig> {
2828
public static final String TOOLS_VERSION = "toolsVersions";
2929
public static final String ADDITIONAL_APP_DEPENDENCIES = "additionalAppDependencies";
3030
public static final String ADDITIONAL_ANDROID_TEST_DEPENDENCIES
3131
= "additionalAndroidTestDependencies";
3232

33-
private JsonObject json;
34-
3533
public EspressoBuildConfig() {
36-
}
37-
38-
public EspressoBuildConfig(JsonObject json) {
39-
this.json = json;
34+
super();
4035
}
4136

4237
public EspressoBuildConfig(String json) {
43-
this(JsonParser.parseString(json).getAsJsonObject());
38+
super(json);
4439
}
4540

4641
private EspressoBuildConfig assignToolsVersionsField(String name, Object value) {
47-
if (json == null) {
48-
json = new JsonObject();
49-
}
50-
boolean hasTools = json.has(TOOLS_VERSION);
51-
JsonObject toolsVersions = hasTools
52-
? json.getAsJsonObject(TOOLS_VERSION)
53-
: new JsonObject();
54-
if (value instanceof Number) {
55-
toolsVersions.addProperty(name, (Number) value);
56-
} else {
57-
toolsVersions.addProperty(name, String.valueOf(value));
58-
}
59-
if (!hasTools) {
60-
json.add(TOOLS_VERSION, toolsVersions);
42+
Optional<Map<String, Object>> toolsVersionsOptional = getOptionValue(TOOLS_VERSION);
43+
Map<String, Object> toolsVersions = toolsVersionsOptional.orElseGet(HashMap::new);
44+
toolsVersions.put(name, value);
45+
if (!toolsVersionsOptional.isPresent()) {
46+
assignOptionValue(TOOLS_VERSION, toolsVersions);
6147
}
6248
return this;
6349
}
6450

6551
private <R> Optional<R> getToolsVersionsFieldValue(String name) {
52+
Optional<Map<String, Object>> toolsVersionsOptional = getOptionValue(TOOLS_VERSION);
6653
//noinspection unchecked
67-
return json == null || !json.has(TOOLS_VERSION)
68-
? Optional.empty()
69-
: Optional.ofNullable((R) json.getAsJsonObject(TOOLS_VERSION).get(name));
54+
return toolsVersionsOptional.map((v) -> (R) v.getOrDefault(name, null));
7055
}
7156

7257
/**
@@ -167,7 +152,7 @@ public EspressoBuildConfig withMinSdk(int apiLevel) {
167152
*/
168153
public Optional<Integer> getMinSdkVersion() {
169154
Optional<Object> result = getToolsVersionsFieldValue("minSdk");
170-
return result.map((v) -> Integer.parseInt(String.valueOf(v)));
155+
return result.map(CapabilityHelpers::toInteger);
171156
}
172157

173158
/**
@@ -188,7 +173,7 @@ public EspressoBuildConfig withTargetSdk(int apiLevel) {
188173
*/
189174
public Optional<Integer> getTargetSdkVersion() {
190175
Optional<Object> result = getToolsVersionsFieldValue("targetSdk");
191-
return result.map((v) -> Integer.parseInt(String.valueOf(v)));
176+
return result.map(CapabilityHelpers::toInteger);
192177
}
193178

194179
/**
@@ -211,35 +196,6 @@ public Optional<String> getKotlinVersion() {
211196
return getToolsVersionsFieldValue("kotlin");
212197
}
213198

214-
private EspressoBuildConfig assignDependenciesField(String name, List<String> value) {
215-
if (json == null) {
216-
json = new JsonObject();
217-
}
218-
boolean hasField = json.has(name);
219-
JsonArray dependencies = hasField
220-
? json.getAsJsonArray(name)
221-
: new JsonArray();
222-
while (dependencies.size() > 0) {
223-
dependencies.remove(0);
224-
}
225-
value.forEach(dependencies::add);
226-
if (!hasField) {
227-
json.add(name, dependencies);
228-
}
229-
return this;
230-
}
231-
232-
private Optional<List<String>> getDependenciesValue(String name) {
233-
return json == null
234-
? Optional.empty()
235-
: Optional.ofNullable(json.getAsJsonArray(name))
236-
.map((v) -> {
237-
List<String> result = new ArrayList<>();
238-
v.forEach((x) -> result.add(String.valueOf(x)));
239-
return result;
240-
});
241-
}
242-
243199
/**
244200
* Set a non-empty array of dependent module names with their versions.
245201
* The scripts add all these items as "implementation" lines of dependencies
@@ -249,7 +205,7 @@ private Optional<List<String>> getDependenciesValue(String name) {
249205
* @return self instance for chaining.
250206
*/
251207
public EspressoBuildConfig withAdditionalAppDependencies(List<String> dependencies) {
252-
return assignDependenciesField(ADDITIONAL_APP_DEPENDENCIES, dependencies);
208+
return assignOptionValue(ADDITIONAL_APP_DEPENDENCIES, dependencies);
253209
}
254210

255211
/**
@@ -258,7 +214,7 @@ public EspressoBuildConfig withAdditionalAppDependencies(List<String> dependenci
258214
* @return Dependent module names with their versions.
259215
*/
260216
public Optional<List<String>> getAdditionalAppDependencies() {
261-
return getDependenciesValue(ADDITIONAL_APP_DEPENDENCIES);
217+
return getOptionValue(ADDITIONAL_APP_DEPENDENCIES);
262218
}
263219

264220
/**
@@ -270,7 +226,7 @@ public Optional<List<String>> getAdditionalAppDependencies() {
270226
* @return self instance for chaining.
271227
*/
272228
public EspressoBuildConfig withAdditionalAndroidTestDependencies(List<String> dependencies) {
273-
return assignDependenciesField(ADDITIONAL_ANDROID_TEST_DEPENDENCIES, dependencies);
229+
return assignOptionValue(ADDITIONAL_ANDROID_TEST_DEPENDENCIES, dependencies);
274230
}
275231

276232
/**
@@ -279,15 +235,6 @@ public EspressoBuildConfig withAdditionalAndroidTestDependencies(List<String> de
279235
* @return Dependent module names with their versions.
280236
*/
281237
public Optional<List<String>> getAdditionalAndroidTestDependencies() {
282-
return getDependenciesValue(ADDITIONAL_ANDROID_TEST_DEPENDENCIES);
283-
}
284-
285-
public JsonObject toJson() {
286-
return Optional.ofNullable(json).orElseGet(JsonObject::new);
287-
}
288-
289-
@Override
290-
public String toString() {
291-
return toJson().toString();
238+
return getOptionValue(ADDITIONAL_ANDROID_TEST_DEPENDENCIES);
292239
}
293240
}

src/main/java/io/appium/java_client/android/options/server/SupportsEspressoBuildConfigOption.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ default T setEspressoBuildConfig(String configPath) {
5050
* @return self instance for chaining.
5151
*/
5252
default T setEspressoBuildConfig(EspressoBuildConfig config) {
53-
return amend(ESPRESSO_BUILD_CONFIG_OPTION, config.toJson().toString());
53+
return amend(ESPRESSO_BUILD_CONFIG_OPTION, config.toString());
5454
}
5555

5656
/**

src/main/java/io/appium/java_client/android/options/signing/SupportsKeystoreOptions.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public interface SupportsKeystoreOptions<T extends BaseOptions<T>> extends
3838
* @param keystoreConfig The keystore config to use.
3939
* @return self instance for chaining.
4040
*/
41-
default T useKeystore(KeystoreConfig keystoreConfig) {
41+
default T setKeystoreConfig(KeystoreConfig keystoreConfig) {
4242
return amend(USE_KEYSTORE_OPTION, true)
4343
.amend(KEYSTORE_PATH_OPTION, keystoreConfig.getPath())
4444
.amend(KEYSTORE_PASSWORD_OPTION, keystoreConfig.getPassword())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.appium.java_client.ios.options.other;
18+
19+
import io.appium.java_client.internal.CapabilityHelpers;
20+
import io.appium.java_client.remote.options.BaseMapOptionData;
21+
22+
import java.time.Duration;
23+
import java.util.Map;
24+
import java.util.Optional;
25+
26+
public class CommandTimeouts extends BaseMapOptionData<CommandTimeouts> {
27+
public static final String DEFAULT_COMMAND = "default";
28+
29+
public CommandTimeouts() {
30+
}
31+
32+
public CommandTimeouts(Map<String, Object> timeouts) {
33+
super(timeouts);
34+
}
35+
36+
public CommandTimeouts(String json) {
37+
super(json);
38+
}
39+
40+
/**
41+
* Sets the timeout for the particular Appium command that
42+
* is proxied to WDA.
43+
* Command names you can find in logs, look for
44+
* "Executing command 'command_name'" records.
45+
* Timeout value is expected to contain max milliseconds to wait for
46+
* the given WDA command to be executed before terminating the session forcefully.
47+
*
48+
* @param commandName The command name.
49+
* @param timeout Command timeout.
50+
* @return self instance for chaining.
51+
*/
52+
public CommandTimeouts withCommandTimeout(String commandName, Duration timeout) {
53+
return assignOptionValue(commandName, timeout.toMillis());
54+
}
55+
56+
/**
57+
* Sets the default timeout for all Appium commands that
58+
* are proxied to WDA.
59+
*
60+
* @param timeout Commands timeout.
61+
* @return self instance for chaining.
62+
*/
63+
public CommandTimeouts withDefaultCommandTimeout(Duration timeout) {
64+
return withCommandTimeout(DEFAULT_COMMAND, timeout);
65+
}
66+
67+
/**
68+
* Get the command timeout.
69+
*
70+
* @param commandName The command name
71+
* @return Timeout value.
72+
*/
73+
public Optional<Duration> getCommandTimeout(String commandName) {
74+
Optional<Object> result = getOptionValue(commandName);
75+
return result.map(CapabilityHelpers::toDuration);
76+
}
77+
}

0 commit comments

Comments
 (0)