owncloud / android-scenario-testing

:iphone: :gear: Android scenario testing using feature files. Gherkin language, Cucumber as tool and Appium interaction with devices/emulators
MIT License
4 stars 2 forks source link
automated-testing cucumber-java cucumber-reports gherkin-language java scenarios testing

Scenarios contained in feature files written in Gherkin language. Available scenarios can be found here.

Defined for the ownCloud Android app

Global overview

Get the code

git clone https://github.com/owncloud/android-scenario-testing.git

Requirements

Different requirements:

How to test

1. Build app

First, build the app from the expected branch/commit to get the test object. Before building, execute the following commands in the app's folder:

gsed -i 's/<bool name="wizard_enabled">true<\/bool>/<bool name="wizard_enabled">false<\/bool>/i' owncloudApp/src/main/res/values/setup.xml
gsed -i 's/<bool name="release_notes_enabled">true<\/bool>/<bool name="release_notes_enabled">false<\/bool>/i' owncloudApp/src/main/res/values/setup.xml
gsed -i '375,376d' owncloudApp/src/main/java/com/owncloud/android/presentation/authentication/LoginActivity.kt
gsed -i '380,414d' owncloudApp/src/main/java/com/owncloud/android/presentation/authentication/LoginActivity.kt

These instructions:

App is built via Android Studio or CLI (gradlew)

After building, the signed ownCloud.apk artifact is located in:

owncloudApp/build/outputs/apk/original/release

move the owncloud.apk to the correct place in the current tests project: /src/test/resources

(in the current repository will be always an owncloud.apk file located in the correct place.)

2. Execute tests

The script executeTests will launch the tests. The following environment variables must be set in advance

    $OC_SERVER_URL (mandatory): URL of ownCloud server to test against
    $APPIUM_URL (optional): Appium server URL.
        If Appium Server is not specified, will be used "localhost:4723/wd/hub"
    $UDID_DEVICE (optional): ID of the device/simulator to execute the tests in.
        This ID could be get by executing  `adb devices`

The script needs some parameters. Check help executeTests -h

To execute all tests but the ignored ones (or any other tagged ones):

export UDID_DEVICE=emulator-5554
export OC_SERVER_URL=https://my.owncloud.server
export APPIUM_URL=localhost:4723
./executeTests -t "not @ignore"

The execution will display step by step how the scenario is being executed.

More info in Cucumber reference

NOTE: Since there are two kinds of backends available (oC10, oCIS), not all tests are suitable to be executed over both. Those tests have been tagged with:

It's important to execute the tests with the mentioned tags to avoid wrong positives. Example commands:

./executeTests -t "not @ignore and not @noocis"
This command will execute tests that are not ignored and suitable for oCIS. If this command is run over an oC10 instance, some tests will fail.

./executeTests -t "not @ignore and not @nooc10"
This command will execute tests that are not ignored and suitable for oC10. If this command is run over an oCIS instance, some tests will fail.

Results

In the folder target, you will find a report with the execution results in html and json formats.

Besides of that, by setting the cucumber.properties file allow to integrate reports with Cucumber reports. An account in such platform (integrated with GitHub) is enough to use it. A new env variable must be set in advance in order to send reports to the platform. Token is provided in the Cucumber Reports account for every collection:

export CUCUMBER_PUBLISH_TOKEN=d97...

Also, in cucumber.properties file with the following values (disabled by default):

cucumber.publish.quiet=false
cucumber.publish.enabled=true

Note: This repository was forked from Cucumber-java skeleton repository, which contains the base skeleton to start working.

Versioning

Up to date: 02/Aug/2024

Cucumber version 7.18.0
Appium version 2.11.2
Appium uiautomator2 driver version 3.7.7
Java client version 9.2.2