Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/the-sdet/appium-cucumber-junit5-mobile-automation-framework

Mobile Automation Framework, A project ready Test Automation Framework, provides a robust solution for automating tests on both Android and iOS devices. With seamless integration for great reporting and logging features, it ensures efficient tracking and debugging of test executions. The framework supports local execution as well as remote testing.
https://github.com/the-sdet/appium-cucumber-junit5-mobile-automation-framework

appium cucumber java junit5 selenium test-automation-framework

Last synced: 6 days ago
JSON representation

Mobile Automation Framework, A project ready Test Automation Framework, provides a robust solution for automating tests on both Android and iOS devices. With seamless integration for great reporting and logging features, it ensures efficient tracking and debugging of test executions. The framework supports local execution as well as remote testing.

Awesome Lists containing this project

README

        

# Comprehensive Mobile Automation Framework

Appium  
Selenium  
Java  
Cucumber  
JUnit5  
MakeMyTrip

This Mobile Automation Framework, A project ready Test Automation Framework, provides a robust solution for automating tests on both
Android and iOS devices. With
seamless integration for great reporting and logging features, it ensures efficient tracking and debugging of test
executions. The framework supports local execution as well as remote testing via platforms like Sauce Labs, offering
flexibility and scalability to your automation workflow.

For Instance, this framework contains the Home Page, Menu Drawer, Flight Page, Flight Search, Filter Validations for Search, etc. for **MakeMyTrip** Android App...

## Tech Stack & Libraries Used

* appium v9.1.0
* selenium v1.18.1
* java v11
* cucumber v7.15.0
* junit 5
* test-automation-toolkit v1.0.2
* maven v3.9.5
* surefire v3.1.2
* gherkin v26.0.1
* lombok v1.18.20
* log4j v2.20.0
* extent v1.14.0
* masterthought-reporting v5.8.0
* apache-poi v5.2.5
* common-io v2.7
* guava.version v33.0.0-jre

## Features:

1. [x] **Cross-Platform Support:** Seamlessly automate tests on both Android and iOS devices.
2. [x] **Rich Reporting:** Generate comprehensive reports to gain insights into test results and performance metrics.
3. [x] **Detailed Logging:** Capture detailed logs for each test run, aiding in debugging and troubleshooting.
4. [x] **Local and Remote Execution:** Execute tests locally for quick iterations or leverage remote execution
capabilities
with platforms like Sauce Labs for broader device coverage.
5. [x] **Scalable Architecture:** Built with scalability in mind to accommodate growing test suites and evolving project
requirements.
6. [x] **Modular Design:** Modular components ensure easy maintenance and extensibility of the framework.
7. [x] **Integration-Friendly:** Easily integrate with Continuous Integration (CI) pipelines for seamless automation
workflows.

## Setup:

### Install the below items for an easy setup

* [Java 11](https://www.oracle.com/in/java/technologies/javase/jdk11-archive-downloads.html)
* [Maven](https://maven.apache.org/download.cgi)
* [Any IDE (IntelliJ)](https://www.jetbrains.com/idea/download/)
* [Node.js (Needed to Manage Appium)](https://nodejs.org/en/download)
* Install Appium
* ``` npm i --location=global appium ```
* ``` appium --version ```
* Install Driver
* Android Driver: ``` appium driver install uiautomator2 ```
* iOS Driver: ``` appium driver install xcuitest ```

### Clone the repository:

```
git clone https://github.com/the-sdet/appium-cucumber-junit5-mobile-automation-framework.git
```

## Configuration:

All the configs can be found in test/resources. Those can be modified as per project requirement.

- config.properties
- android-config.properties
- ios-config.properties
- junit-platform.properties
- extent.properties

## Tagging The Features and Scenarios

When we talk in Cucumber context, tags are one of the most vital components. We need to tag our features and scenarios
well to group them and run them as we need.

Tags are mentioned with @ as prefix above the feature or scenario. A feature/scenario can have multiple tags as well. A
tag on feature level is auto inherited to the scenarios in that feature. So, no need to repeat same tag on each
scenario, it can be simply added to the feature.

```
@myFeature
Feature: Sample Feature

@Smoke @Regression
Scenario: Scenario One
Given I tag a scenario
When I select tests with that tag for execution
Then my tagged scenario is executed

@Sanity
Scenario: Scenario Two
Given I tag a scenario
When I select tests with that tag for execution
Then my tagged scenario is executed
```

## Execution:

There are multiple ways to execute the tests.

* Run feature/scenario directly from feature file.
* Run the TestRunner inside src/test/java/runner/TestRunner.java
* Run using Maven CLI

Executing tests using Maven CLI is the preferred option as it's configured in a such a way that, you can almost provide
most of the configs from maven command itself at the runtime rather than actually modifying them in code.

## Examples of some configs that can be altered from CMD for the specific run

All the below configs are optional. if NOT provided from CMD, already defined values will be picked.

* execution.type
* platform
* env
* sauce.url
* sauce.username
* sauce.password
* screenshot
* report.name

#### Executing on local or remote (sauce labs)
```
mvn clean install -Dexecution.type=local
```
```
mvn clean install -Dexecution.type=remote
```

#### Screenshot Options
```
mvn clean install -Dscreenshot=only.pass
```
```
mvn clean install -Dscreenshot=only.fail
```
```
mvn clean install -Dscreenshot=all
```
#### Platform Options
```
mvn clean install -Dplatform=android
```
```
mvn clean install -Dplatform=ios
```

#### Sauce Options
```
mvn clean install -Dsauce.url=sauce-url -Dsauce.username=username -Dsauce.password=pasword
```
#### Environment
```
mvn clean install -Denv=stg
```
#### Report Name
```
mvn clean install -Dreport.name="Automation Test Summary - The SDET"
```

### Executing all the tests

All the features & it's scenarios can be executed by using below command.

```
mvn clean install
```

### Executing selected tests

Cucumber tags are mapped to JUnit tags. Note that the @ symbol is not part of the JUnit tag.
When using Maven, tags can be provided from the CLI using the groups and excludedGroups
parameters.

Cucumber Tag Expression uses cucumber.filter.tags for filtering

```
mvn clean install -Dcucumber.filter.tags="@Regression"
```

JUnit Tag Expression groups and excludedGroups for filtering

```
mvn clean install -Dgroups="Regression"
```

_*** While using JUnit5, JUnit5 tag expressions are preferred over Cucumber Tag Expression and Cucumber Tag Expression
can be avoided for better results._

### JUnit5 Tag Expressions

Tag expressions are boolean expressions with the operators !, & and |. In addition, ( and ) can be used to adjust for
operator precedence.

Operator
Meaning
Associativity

!
not
right

&
and
left

|
or
left

If you are tagging your tests across multiple dimensions, tag expressions help you to select which tests to execute.
When tagging by test type (e.g., micro, integration, end-to-end) and feature (e.g., product, catalog, shipping), the
following tag expressions can be useful.

Tag Expression
Selection

product
all tests for product

catalog | shipping
all tests for catalog plus all tests for shipping

catalog & shipping
all tests for the intersection between catalog and shipping

product & !end-to-end
all tests for product, but not the end-to-end tests

(micro | integration) & (product | shipping)
all micro or integration tests for product or shipping

### Executing selected tests (filter using tags/tag expression)

Run only Regression Tests

```
mvn clean install -Dgroups="Regression"
```

Run Regression Tests but exclude Profile Tests

```
mvn clean install -Dgroups="Regression" -DexcludedGroups="Profile"
```

or

```
mvn clean install -Dgroups="Regression & !Profile"
```

Run Home Page Tests but only Section One of Home Page not Section Two and Three

```
mvn clean install -Dgroups="HomePage & SectionOne"
```

By default, @ignore tag has been set to skip those tests. This can be changed by removing the below line from
TestRunner.

```
@ExcludeTags("ignore")
```

It's equivalent to

```
mvn clean install -DexcludedGroups="ignore"
```

## Reporting

Various Reports are generated in testReports directory after the execution

1. [x] **Cucumber HTML Report** -> testReports/CucumberReport.html
2. [x] **Extent HTML Report** -> testReports/ExtentReport.html
3. [x] **Extent PDF Report** -> testReports/ExtentReport.pdf
4. [x] **Master thought Cucumber Report** -> testReports/cucumber-html-reports/overview-features.html
5. [x] **Timeline Report** -> testReports/timelineReport/index.html

## Logs

Logs are written to console and as well as to log file. Log file can be found at z_logs directory

## Authors

pabitra-qa
[@the-sdet](https://github.com/the-sdet)

pabitra-qa
[@pabitra-qa](https://github.com/pabitra-qa)

## About Me

I'm a dedicated and passionate Software Development Engineer in Test (SDET) trying to help the community.

## Connect With Me

Connect with me over LinkedIn or visit my Website...

pabitra-qa
 

## Feedback

If you have any feedback, please reach out to us at [[email protected]](mailto:[email protected]).