Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Run tests on the JUnit Jupiter Platform #1721

Merged
merged 23 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dcfdbbe
refactor!: Migrated all tests to JUnit 5
RameshBabuPrudhvi Jul 25, 2022
ca0378b
refactor!: updated missing junit tests
RameshBabuPrudhvi Jul 25, 2022
667f58f
refactor!: updated review comments
RameshBabuPrudhvi Jul 25, 2022
ccf1349
refactor!: updated import statement order
RameshBabuPrudhvi Jul 25, 2022
9c12104
refactor!: Removed unwanted test methods
RameshBabuPrudhvi Jul 25, 2022
e904926
refactor!: Fixed Formatter
RameshBabuPrudhvi Jul 25, 2022
7fa1cb8
refactor!: Updated existing class specific check styles
RameshBabuPrudhvi Jul 26, 2022
6fdd68b
refactor!: Updated existing class specific check styles
RameshBabuPrudhvi Jul 26, 2022
7c2fae3
refactor!: Updated check styles
RameshBabuPrudhvi Jul 26, 2022
b2b646d
refactor!: Updated check styles
RameshBabuPrudhvi Jul 26, 2022
c1c6aec
refactor!: Updated check styles
RameshBabuPrudhvi Jul 26, 2022
fc379cb
Revert noisy changes
valfirst Jul 26, 2022
9904f4e
refactor!: Updated WidgetTests
RameshBabuPrudhvi Jul 27, 2022
e95df72
refactor!: Reverted WidgetTest changes and execute using vintage engine
RameshBabuPrudhvi Jul 27, 2022
4a5dda0
refactor!: update import
RameshBabuPrudhvi Jul 27, 2022
a849e46
refactor!: Reverted format changes
RameshBabuPrudhvi Jul 27, 2022
8fd7141
refactor!: Added Test annotation for all test override methods
RameshBabuPrudhvi Jul 27, 2022
b4b026d
refactor!: Reverted Widget Tests
RameshBabuPrudhvi Jul 27, 2022
589709b
Widget Tests (#1)
RameshBabuPrudhvi Jul 27, 2022
5abd0e3
refactor!: Added missing import
RameshBabuPrudhvi Jul 27, 2022
022b576
refactor!: Updated Widget Parameterized Tests
RameshBabuPrudhvi Jul 27, 2022
dd77163
refactor!: Updated Tests
RameshBabuPrudhvi Jul 27, 2022
3741d7c
refactor!: Merged WidgetTest classes
RameshBabuPrudhvi Jul 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies {
implementation 'commons-io:commons-io:2.11.0'
implementation 'org.slf4j:slf4j-api:1.7.36'

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation (group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '5.2.1') {
exclude group: 'org.seleniumhq.selenium'
Expand Down Expand Up @@ -192,7 +192,7 @@ processResources {
}

task xcuiTest( type: Test ) {
useJUnit()
useJUnitPlatform()
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
filter {
Expand All @@ -207,7 +207,7 @@ task xcuiTest( type: Test ) {
}

task uiAutomationTest( type: Test ) {
useJUnit()
useJUnitPlatform()
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
filter {
Expand All @@ -223,7 +223,7 @@ task uiAutomationTest( type: Test ) {
}

task miscTest( type: Test ) {
useJUnit()
useJUnitPlatform()
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
filter {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package io.appium.java_client.android;

import static io.appium.java_client.TestUtils.getCenter;
import static io.appium.java_client.touch.WaitOptions.waitOptions;
import static io.appium.java_client.touch.offset.ElementOption.element;
import static java.time.Duration.ofSeconds;
import static org.junit.Assert.assertNotEquals;

import io.appium.java_client.AppiumBy;
import io.appium.java_client.functions.ActionSupplier;
import io.appium.java_client.touch.offset.ElementOption;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;

import java.util.List;

import static io.appium.java_client.TestUtils.getCenter;
import static io.appium.java_client.touch.WaitOptions.waitOptions;
import static io.appium.java_client.touch.offset.ElementOption.element;
import static java.time.Duration.ofSeconds;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
RameshBabuPrudhvi marked this conversation as resolved.
Show resolved Hide resolved

public class AndroidAbilityToUseSupplierTest extends BaseAndroidTest {

private final ActionSupplier<AndroidTouchAction> horizontalSwipe = () -> {
Expand All @@ -26,8 +26,8 @@ public class AndroidAbilityToUseSupplierTest extends BaseAndroidTest {
Point location = gallery.getLocation();
Point center = getCenter(gallery, location);

ElementOption pressOption = element(images.get(2),-10,center.y - location.y);
ElementOption moveOption = element(gallery, 10,center.y - location.y);
ElementOption pressOption = element(images.get(2), -10, center.y - location.y);
ElementOption moveOption = element(gallery, 10, center.y - location.y);

return new AndroidTouchAction(driver)
.press(pressOption)
Expand All @@ -37,15 +37,16 @@ public class AndroidAbilityToUseSupplierTest extends BaseAndroidTest {
};

private final ActionSupplier<AndroidTouchAction> verticalSwiping = () ->
new AndroidTouchAction(driver)
.press(element(driver.findElement(AppiumBy.accessibilityId("Gallery"))))
new AndroidTouchAction(driver)
.press(element(driver.findElement(AppiumBy.accessibilityId("Gallery"))))

.waitAction(waitOptions(ofSeconds(2)))
.waitAction(waitOptions(ofSeconds(2)))

.moveTo(element(driver.findElement(AppiumBy.accessibilityId("Auto Complete"))))
.release();
.moveTo(element(driver.findElement(AppiumBy.accessibilityId("Auto Complete"))))
.release();
RameshBabuPrudhvi marked this conversation as resolved.
Show resolved Hide resolved

@Test public void horizontalSwipingWithSupplier() {
@Test
public void horizontalSwipingWithSupplier() {
Activity activity = new Activity("io.appium.android.apis", ".view.Gallery1");
driver.startActivity(activity);
WebElement gallery = driver.findElement(By.id("io.appium.android.apis:id/gallery"));
Expand All @@ -58,7 +59,8 @@ public class AndroidAbilityToUseSupplierTest extends BaseAndroidTest {
gallery.findElements(AppiumBy.className("android.widget.ImageView")).size());
}

@Test public void verticalSwipingWithSupplier() throws Exception {
@Test
public void verticalSwipingWithSupplier() throws Exception {
driver.resetApp();
driver.findElement(AppiumBy.accessibilityId("Views")).click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,54 @@

package io.appium.java_client.android;

import static org.junit.Assert.assertEquals;

import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class AndroidActivityTest extends BaseAndroidTest {

@Before public void setUp() {
@BeforeEach
public void setUp() {
Activity activity = new Activity("io.appium.android.apis", ".ApiDemos");
driver.startActivity(activity);
}

@Test public void startActivityInThisAppTestCase() {
@Test
public void startActivityInThisAppTestCase() {
Activity activity = new Activity("io.appium.android.apis",
".accessibility.AccessibilityNodeProviderActivity");
".accessibility.AccessibilityNodeProviderActivity");
driver.startActivity(activity);
assertEquals(driver.currentActivity(),
".accessibility.AccessibilityNodeProviderActivity");
".accessibility.AccessibilityNodeProviderActivity");
}

@Test public void startActivityWithWaitingAppTestCase() {
@Test
public void startActivityWithWaitingAppTestCase() {
final Activity activity = new Activity("io.appium.android.apis",
".accessibility.AccessibilityNodeProviderActivity")
".accessibility.AccessibilityNodeProviderActivity")
.setAppWaitPackage("io.appium.android.apis")
.setAppWaitActivity(".accessibility.AccessibilityNodeProviderActivity");
driver.startActivity(activity);
assertEquals(driver.currentActivity(),
".accessibility.AccessibilityNodeProviderActivity");
".accessibility.AccessibilityNodeProviderActivity");
}

@Test public void startActivityInNewAppTestCase() {
@Test
public void startActivityInNewAppTestCase() {
Activity activity = new Activity("com.android.settings", ".Settings");
driver.startActivity(activity);
assertEquals(driver.currentActivity(), ".Settings");
driver.pressKey(new KeyEvent(AndroidKey.BACK));
assertEquals(driver.currentActivity(), ".ApiDemos");
}

@Test public void startActivityInNewAppTestCaseWithoutClosingApp() {
@Test
public void startActivityInNewAppTestCaseWithoutClosingApp() {
Activity activity = new Activity("io.appium.android.apis",
".accessibility.AccessibilityNodeProviderActivity");
".accessibility.AccessibilityNodeProviderActivity");
driver.startActivity(activity);
assertEquals(driver.currentActivity(), ".accessibility.AccessibilityNodeProviderActivity");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@

package io.appium.java_client.android;

import static org.junit.Assert.assertNotEquals;
import org.junit.jupiter.api.Test;

import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

public class AndroidAppStringsTest extends BaseAndroidTest {

@Test public void getAppStrings() {
@Test
public void getAppStrings() {
RameshBabuPrudhvi marked this conversation as resolved.
Show resolved Hide resolved
assertNotEquals(0, driver.getAppStringMap().size());
}

@Test public void getGetAppStringsUsingLang() {
@Test
public void getGetAppStringsUsingLang() {
assertNotEquals(0, driver.getAppStringMap("en").size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@

package io.appium.java_client.android;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import io.appium.java_client.android.connection.ConnectionState;
import io.appium.java_client.android.connection.ConnectionStateBuilder;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class AndroidConnectionTest extends BaseAndroidTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,48 @@

package io.appium.java_client.android;

import static org.junit.Assert.assertEquals;

import io.appium.java_client.NoSuchContextException;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class AndroidContextTest extends BaseAndroidTest {

@BeforeClass public static void beforeClass2() throws Exception {
@BeforeAll
public static void beforeClass2() throws Exception {
Activity activity = new Activity("io.appium.android.apis", ".view.WebView1");
driver.startActivity(activity);
Thread.sleep(20000);
}

@Test public void testGetContext() {
@Test
public void testGetContext() {
assertEquals("NATIVE_APP", driver.getContext());
}

@Test public void testGetContextHandles() {
@Test
public void testGetContextHandles() {
assertEquals(driver.getContextHandles().size(), 2);
}

@Test public void testSwitchContext() {
@Test
public void testSwitchContext() {
driver.getContextHandles();
driver.context("WEBVIEW_io.appium.android.apis");
assertEquals(driver.getContext(), "WEBVIEW_io.appium.android.apis");
driver.context("NATIVE_APP");
assertEquals(driver.getContext(), "NATIVE_APP");
}

@Test(expected = NoSuchContextException.class) public void testContextError() {
driver.context("Planet of the Ape-ium");
assertEquals("Planet of the Ape-ium", driver.getContext());
@Test
public void testContextError() {
assertThrows(NoSuchContextException.class,
() -> {
driver.context("Planet of the Ape-ium");
assertEquals("Planet of the Ape-ium", driver.getContext());
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.appium.java_client.AppiumBy;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.json.Json;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;

import static org.junit.Assert.assertNotNull;
RameshBabuPrudhvi marked this conversation as resolved.
Show resolved Hide resolved
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class AndroidDataMatcherTest extends BaseEspressoTest {

@Test
public void testFindByDataMatcher() {
final WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions
.elementToBeClickable(AppiumBy.accessibilityId("Graphics")));
.elementToBeClickable(AppiumBy.accessibilityId("Graphics")));
driver.findElement(AppiumBy.accessibilityId("Graphics")).click();

String selector = new Json().toJson(ImmutableMap.of(
"name", "hasEntry",
"args", ImmutableList.of("title", "Sweep")
"name", "hasEntry",
"args", ImmutableList.of("title", "Sweep")
));

assertNotNull(wait.until(ExpectedConditions
.presenceOfElementLocated(AppiumBy.androidDataMatcher(selector))));
.presenceOfElementLocated(AppiumBy.androidDataMatcher(selector))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,11 @@

package io.appium.java_client.android;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import io.appium.java_client.appmanagement.ApplicationState;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.ScreenOrientation;
import org.openqa.selenium.html5.Location;

Expand All @@ -39,6 +29,11 @@
import java.util.ArrayList;
import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.jupiter.api.Assertions.*;

public class AndroidDriverTest extends BaseAndroidTest {

@Test
Expand Down