Skip to content

Commit f955fb9

Browse files
authored
Cleaned up test codes (appium#466)
* Deleted unnecessary codes * Move functional tests to correct class * Move some tests * Created search_context/windows_test * [functional] Created search_context package * Remove class method decolator * Fix import error * Add BaseTestCase for ios functional testcases * Add test_helper for android functional test * Add __init__.py * Deleted unused imports
1 parent a2b9440 commit f955fb9

30 files changed

Lines changed: 174 additions & 219 deletions

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[settings]
22
multi_line_output = 3
33
known_third_party = dateutil,httpretty,pytest,selenium,setuptools,urllib3,mock,sauceclient
4-
known_first_party = test
4+
known_first_party = test,appium

appium/webdriver/extensions/android/common.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@ def current_package(self):
5353
"""
5454
return self.execute(Command.GET_CURRENT_PACKAGE)['value']
5555

56-
57-
def _addCommands(self):
58-
self.command_executor._commands[Command.GET_CURRENT_PACKAGE] = \
59-
('GET', '/session/$sessionId/appium/device/current_package')
60-
self.command_executor._commands[Command.END_TEST_COVERAGE] = \
61-
('POST', '/session/$sessionId/appium/app/end_test_coverage')
62-
self.command_executor._commands[Command.OPEN_NOTIFICATIONS] = \
63-
('POST', '/session/$sessionId/appium/device/open_notifications')
56+
def _addCommands(self):
57+
self.command_executor._commands[Command.GET_CURRENT_PACKAGE] = \
58+
('GET', '/session/$sessionId/appium/device/current_package')
59+
self.command_executor._commands[Command.END_TEST_COVERAGE] = \
60+
('POST', '/session/$sessionId/appium/app/end_test_coverage')
61+
self.command_executor._commands[Command.OPEN_NOTIFICATIONS] = \
62+
('POST', '/session/$sessionId/appium/device/open_notifications')

appium/webdriver/webdriver.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,6 @@ def _addCommands(self):
438438
('POST', '/session/$sessionId/touch/perform')
439439
self.command_executor._commands[Command.MULTI_ACTION] = \
440440
('POST', '/session/$sessionId/touch/multi/perform')
441-
self.command_executor._commands[Command.GET_CURRENT_PACKAGE] = \
442-
('GET', '/session/$sessionId/appium/device/current_package')
443-
self.command_executor._commands[Command.END_TEST_COVERAGE] = \
444-
('POST', '/session/$sessionId/appium/app/end_test_coverage')
445-
self.command_executor._commands[Command.OPEN_NOTIFICATIONS] = \
446-
('POST', '/session/$sessionId/appium/device/open_notifications')
447441
self.command_executor._commands[Command.SET_IMMEDIATE_VALUE] = \
448442
('POST', '/session/$sessionId/appium/element/$id/value')
449443

ci-jobs/functional/run_android_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
displayName: Create and run Emulator
1212
- script: |
1313
cd test/functional/android
14-
py.test ${{ parameters.testFiles}} ${{ parameters.pytestOpt }}
14+
python -m pytest ${{ parameters.testFiles}} ${{ parameters.pytestOpt }}
1515
displayName: Run Android functional tests
1616
- template: ./publish_test_result.yml
1717
- template: ./save_appium_log.yml

ci-jobs/functional/run_ios_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
xcodeVersion: ${{ parameters.xcodeForIOS }}
1212
- script: |
1313
cd test/functional/ios
14-
py.test ${{ parameters.testFiles}} ${{ parameters.pytestOpt }}
14+
python -m pytest ${{ parameters.testFiles}} ${{ parameters.pytestOpt }}
1515
displayName: Run iOS functional tests
1616
- template: ./publish_test_result.yml

ci-jobs/functional_test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
name: 'func_test_ios1'
1414
vmImage: ${{ parameters.vmImage }}
1515
pytestOpt: ${{ parameters.pytestOpt }}
16-
testFiles: 'find_*.py remote_fs_tests.py safari_tests.py execute_driver_tests.py'
16+
testFiles: 'search_context/find_by_*.py remote_fs_tests.py safari_tests.py execute_driver_tests.py'
1717
CI: ${{ parameters.ci }}
1818
xcodeForIOS: ${{ parameters.xcodeForIOS }}
1919
- template: ./functional/run_ios_test.yml
@@ -29,7 +29,7 @@ jobs:
2929
name: 'func_test_android1'
3030
vmImage: ${{ parameters.vmImage }}
3131
pytestOpt: ${{ parameters.pytestOpt }}
32-
testFiles: 'device_time_tests.py find_by_accessibility_id_tests.py find_by_image_tests.py'
32+
testFiles: 'device_time_tests.py search_context/find_by_*.py'
3333
sdkVer: ${{ parameters.androidSdkVer }}
3434
CI: ${{ parameters.ci }}
3535
- template: ./functional/run_android_test.yml
@@ -69,7 +69,7 @@ jobs:
6969
name: 'func_test_android6'
7070
vmImage: ${{ parameters.vmImage }}
7171
pytestOpt: ${{ parameters.pytestOpt }}
72-
testFiles: 'webdriver_tests.py'
72+
testFiles: 'common_tests.py'
7373
sdkVer: ${{ parameters.androidSdkVer }}
7474
CI: ${{ parameters.ci }}
7575
- template: ./functional/run_android_test.yml

test/functional/android/applications_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ def test_app_strings_with_language_and_file(self):
7272
strings = self.driver.app_strings('en', 'some_file')
7373
self.assertEqual(u'You can\'t wipe my data, you are a monkey!', strings[u'monkey_wipe_data'])
7474

75+
def test_reset(self):
76+
self.driver.reset()
77+
self.assertTrue(self.driver.is_app_installed('com.example.android.apis'))
78+
7579

7680
if __name__ == '__main__':
7781
suite = unittest.TestLoader().loadTestsFromTestCase(ApplicationsTests)

test/functional/android/webdriver_tests.py renamed to test/functional/android/common_tests.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from .helper.test_helper import BaseTestCase, wait_for_element
2525

2626

27-
class WebdriverTests(BaseTestCase):
27+
class CommonTests(BaseTestCase):
2828

2929
def test_current_package(self):
3030
package = self.driver.current_package
@@ -35,10 +35,6 @@ def test_end_test_coverage(self):
3535
self.driver.end_test_coverage(intent='android.intent.action.MAIN', path='')
3636
sleep(5)
3737

38-
def test_reset(self):
39-
self.driver.reset()
40-
self.assertTrue(self.driver.is_app_installed('com.example.android.apis'))
41-
4238
def test_open_notifications(self):
4339
if is_ci():
4440
# TODO Due to unexpected dialog, "System UI isn't responding"
@@ -71,5 +67,5 @@ def test_open_notifications(self):
7167

7268

7369
if __name__ == '__main__':
74-
suite = unittest.TestLoader().loadTestsFromTestCase(WebdriverTests)
70+
suite = unittest.TestLoader().loadTestsFromTestCase(CommonTests)
7571
unittest.TextTestRunner(verbosity=2).run(suite)

test/functional/android/search_context/__init__.py

Whitespace-only changes.

test/functional/android/find_by_accessibility_id_tests.py renamed to test/functional/android/search_context/find_by_accessibility_id_tests.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
import unittest
1616

1717
from appium.webdriver.common.mobileby import MobileBy
18-
19-
from ..test_helper import is_ci
20-
from .helper.test_helper import BaseTestCase, wait_for_element
18+
from test.functional.android.helper.test_helper import (
19+
BaseTestCase,
20+
wait_for_element
21+
)
22+
from test.functional.test_helper import is_ci
2123

2224

2325
class FindByAccessibilityIDTests(BaseTestCase):

0 commit comments

Comments
 (0)