Run E2E Tests only if needed
This commit is contained in:
parent
aff1b062e1
commit
dcf196ec4a
27
release.sh
27
release.sh
|
@ -102,23 +102,21 @@ function test() {
|
|||
test_image=test_img
|
||||
test_container=test_con
|
||||
|
||||
# Run unit test
|
||||
echo "----UNIT TEST----"
|
||||
(export ANDROID_HOME=/root && export ANDROID_VERSION=$test_android_version && export API_LEVEL=$test_api_level \
|
||||
&& export PROCESSOR=$test_processor && export SYS_IMG=$test_sys_img && export IMG_TYPE=$test_img_type \
|
||||
&& nosetests src/tests/unit -v)
|
||||
|
||||
# Run integration test
|
||||
# Integration test must be run only for linux OS / x86 image to reduce duration of test execution
|
||||
if [ "$(uname -s)" == 'Linux' ]; then
|
||||
# Run e2e tests
|
||||
# E2E tests must be run only for linux OS / x86 image to reduce duration of test execution
|
||||
if [ "$(uname -s)" == 'Linux' ] && [ "$E2E" = true ]; then
|
||||
echo "----BUILD TEST IMAGE----"
|
||||
docker build -t $test_image --build-arg ANDROID_VERSION=$test_android_version \
|
||||
--build-arg BUILD_TOOL=$LATEST_BUILD_TOOL --build-arg API_LEVEL=$test_api_level \
|
||||
--build-arg PROCESSOR=$test_processor --build-arg SYS_IMG=$test_sys_img \
|
||||
--build-arg IMG_TYPE=$test_img_type -f docker/Emulator_x86 .
|
||||
|
||||
echo "----RUN E2E TEST----"
|
||||
docker run --privileged -d -p 4723:4723 -p 6080:6080 -e APPIUM=True --name $test_container $test_image
|
||||
echo "----REMOVE OLD TEST CONTAINER----"
|
||||
docker kill $test_container && docker rm $test_container
|
||||
|
||||
echo "----PREPARE CONTAINER----"
|
||||
docker run --privileged -d -p 4723:4723 -p 6080:6080 -e APPIUM=True -e DEVICE="Samsung Galaxy S6" --name $test_container $test_image
|
||||
docker cp example/sample_apk $test_container:/root/tmp
|
||||
attempt=0
|
||||
while [ ${attempt} -le 10 ]; do
|
||||
attempt=$(($attempt + 1))
|
||||
|
@ -137,11 +135,18 @@ function test() {
|
|||
fi
|
||||
done
|
||||
|
||||
echo "----RUN E2E TESTS----"
|
||||
nosetests src/tests/e2e -v
|
||||
|
||||
echo "----REMOVE TEST CONTAINER----"
|
||||
docker kill $test_container && docker rm $test_container
|
||||
fi
|
||||
|
||||
# Run unit tests (After e2e test to get coverage result)
|
||||
echo "----UNIT TESTS----"
|
||||
(export ANDROID_HOME=/root && export ANDROID_VERSION=$test_android_version && export API_LEVEL=$test_api_level \
|
||||
&& export PROCESSOR=$test_processor && export SYS_IMG=$test_sys_img && export IMG_TYPE=$test_img_type \
|
||||
&& nosetests src/tests/unit -v)
|
||||
}
|
||||
|
||||
function build() {
|
||||
|
|
29
src/tests/e2e/test_android_apk.py
Normal file
29
src/tests/e2e/test_android_apk.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
"""e2e test to test sample android application inside docker-android"""
|
||||
from unittest import TestCase
|
||||
|
||||
from appium import webdriver
|
||||
|
||||
|
||||
class TestE2EApp(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
desired_caps = {
|
||||
'platformName': 'Android',
|
||||
'deviceName': 'Android Emulator',
|
||||
'automationName': 'UIAutomator2',
|
||||
'app': '/root/tmp/sample_apk_debug.apk'
|
||||
}
|
||||
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
|
||||
|
||||
def test_calculation(self):
|
||||
text_fields = self.driver.find_elements_by_class_name('android.widget.EditText')
|
||||
text_fields[0].send_keys(4)
|
||||
text_fields[1].send_keys(6)
|
||||
|
||||
btn_calculate = self.driver.find_element_by_class_name('android.widget.Button')
|
||||
btn_calculate.click()
|
||||
|
||||
self.assertEqual('10', text_fields[2].text)
|
||||
|
||||
def tearDown(self):
|
||||
self.driver.quit()
|
Loading…
Reference in a new issue