The Appium 2 Project is a Java-based test automation framework built with Appium 2, supporting the testing of native and web mobile applications in both local and cloud-based (BrowserStack) environments.
- About the Project
- Key Features and Technical Solutions
- Tech Stack
- Tested Applications
- Setup and Prerequisites
- Usage and Running Tests
- Screenshots and Videos of the Tests
This project was created for learning purposes, allowing me as a junior software tester to practice and deepen my knowledge in the field of test automation, particularly in testing mobile and web-based systems. I aimed to create a test framework that, in its structure and operation, resembles solutions used in professional work environments.
The framework was built entirely from scratch. The core technologies are Java, Appium 2, Selenium, TestNG, and Log4j. The system can automatically manage the Appium server, generate logs and reports (Extent Reports, as well as HTML-formatted email reports), and take screenshots in case of failure. It is also capable of uploading these artifacts to Netlify and sending them via email using the SendGrid API. Although these functions are often handled centrally in a real CI/CD environment, my goal was to understand their operation by implementing them manually, thereby learning new Java libraries and techniques.
The tests operate in a data-driven manner, with input data sourced from JSON files. During the design phase, key considerations were modularity, reusability, and easy maintainability. Code quality was also enhanced using tools like PMD and SpotBugs.
Of course, there are still countless opportunities for development and refinement. My next goals include implementing parallel test execution and CI/CD integration, for example, using Jenkins.
Testing was performed on a real Android device (Xiaomi Redmi Note 8T - Android 11) and in the BrowserStack cloud service, which I demonstrate in the videos below.
The project follows modern software development and test automation best practices:
- Page Object Model (POM): UI elements and their corresponding actions are separated from the test logic, resulting in clean and maintainable code.
- Data-Driven Configuration: Driver capabilities, environment settings, and test data are stored in external
JSONand.propertiesfiles. This allows for modifying the test environment without changing the Java code. - Factory and Builder Design Patterns:
DriverFactory: A central "factory" for creating variousAndroidDriverinstances (native/web, local/cloud).OptionsBuilderclasses: Responsible for the dynamic and readable assembly of complex Appium capabilities objects.
- POJO and Enum Classes for Structured Data Representation:
- The system uses
POJOclasses (e.g.,AppiumOptionsData) to read JSON configurations and test data with the help of Jackson. This provides type safety and better readability compared to rawMapobjects. Enumsare used for the safe handling of fixed, predefined values (e.g., execution environments), preventing errors from typos.
- The system uses
- Layered Logic with Steps, Assertions, and Providers:
- Tests are broken down into well-defined layers. Page Object classes contain reusable, business-level steps (e.g.,
login()), while test methods are responsible for calling these steps and performing assertions. - Data-driven testing is supported through DataProvider classes.
- Tests are broken down into well-defined layers. Page Object classes contain reusable, business-level steps (e.g.,
- Environment-Dependent Execution: A single configuration switch allows for toggling between local (on a real device or emulator) and cloud-based (BrowserStack) execution.
- Programmatic Server Management: The
AppiumServerManagercan automatically start/stop the Appium server, eliminating the need for manual intervention. - Detailed Reporting: The system offers two parallel reporting mechanisms:
- ExtentReports: Generates interactive, visual HTML reports with screenshots on failure.
- Custom Email Reporting: Uses the SendGrid API to send HTML-formatted notifications, providing a reporting mechanism independent of any CI/CD system.
- Timestamped Logging to File (
logback): TheLog4jlogging system creates a separate, timestamped log file for each test run and server start, preventing log overwrites and simplifying debugging. The logging level and target location are configurable in thelog4j.propertiesfile for test runs and inconfig.propertiesfor the Appium server. - Exception Handling with Custom Exception Hierarchy: The framework introduces dedicated custom exception classes (e.g.,
ConfigurationException,JsonReadException,LogFileException) all extending a baseAppiumProjectException. This promotes clearer, contextualized error reporting and better maintainability. - Refactoring Based on the DRY (Don't Repeat Yourself) Principle: The entire project is built following the DRY principle. Frequently repeated operations—such as driver management, configuration reading, or common UI interactions—are centralized in reusable components. This significantly reduces code duplication and increases long-term maintainability.
The project uses the latest or near-latest versions of the following main technologies and libraries:
- Java 22.0
- Maven 3.9.9
- Appium 2.19.0
- Appium Java Client 9.2.2
- Selenium 4.22.0
- TestNG 7.10.2
- Log4j 2.24.0
- Jackson 2.19
- Extent reports 5.1.2
- Sendgrid 4.10.3 (for email sending)
- Netlify-CLI 18.0.4 (for uploading files to a server)
- SauceLabs Swag Labs (native) app (MyDemoAppRN.1.3.0.build-244)
- Battery Alarm (native) app (v76) (Battery Alarm webpage)
- CURA Healthcare Service (web) app (Katalon demo webpage)
- Chrome version: 137.0.7151.89
- Java Development Kit (JDK) 22 or newer
- Apache Maven – for building the project and running tests
- Node.js and npm – for installing and running Appium
- Appium 2 – installed globally (
npm install -g appium@next) - Android SDK – it is recommended to install it with Android Studio, which also provides the necessary tools and an AVD manager
- Registration and configuration of external services:
- Sendgrid – for sending email-based test reports. Configuration file:
src/main/resources/emailsendingdata/sendgrid_account.json - Netlify – for public access to files in test reports (e.g., screenshots), a simple Netlify account and deploy are required
- BrowserStack – for test execution in a cloud-based device farm. Configuration files:
src/test/resources/testdatafiles/options/browserstack/
- Sendgrid – for sending email-based test reports. Configuration file:
- Execution Environment and Browser: The following settings can be configured in the
src/main/resources/config.propertiesfile:run.environment: The test execution environment. Possible values:localorcloud(BrowserStack).browser.type: The browser used for web tests. Possible values:chromeorfirefox.
- Driver Capabilities: Platform- and environment-specific Appium settings are located in separate JSON files under the following path:
src/test/resources/testdatafiles/options/appium/.
The framework uses TestNG to configure and run tests, leveraging its advanced control features.
- Test Suites: Predefined execution packages for various testing purposes (e.g., quick checks, full regression) are located in the
src/test/resources/testng-configs/folder. This allows running only relevant tests, optimizing time and resources.smoke-tests.xml: Fast-running tests to check basic functionality.regression-tests.xml: A test suite ensuring full functional coverage of the system.
- TestNG Groups: Tests can be logically separated using the
@Test(groups = {"smoke"})annotation. - Data-Driven Testing (@DataProvider): The framework supports a data-driven testing approach. The
DataProviderTestsclass for the CURA H.S. application provides an example of how to read test data (username, password) from an external JSON file (from thesrc/test/resources/testdatafiles/testinputs/folder). TheCuraLoginTestDataProviderclass separates the data supply from the test logic, allowing the same test case to be executed with multiple input combinations. - Priority and Dependencies: The
@Test(priority = ...)annotation allows specifying the execution order of tests, which is particularly useful for testing complex, interdependent user flows.
Tests can be run in two ways – in both cases, the testng.xml suite files form the basis.
The pom.xml file is configured with the Maven Surefire Plugin to run tests. The following commands should be executed from the project's root directory:
-
Run the default suite (based on
pom.xml):mvn clean test -
Run a specific suite with the
-Dsurefire.suiteXmlFilesparameter:mvn clean test -Dsurefire.suiteXmlFiles=src/test/resources/testng-configs/testng-smoke.xml
Any modern Java IDE (e.g., IntelliJ IDEA or Eclipse) with TestNG support allows running tests via a graphical interface, either at the level of individual test suites or even single methods.
|
EndToEnd test (Sauce Labs) |
Appointment conf. test (Cura) |
Test on BrowserStack (Sauce Labs) |
License: this project is licensed under the MIT License. Created by: Szabolcs Szigli
In Hungarian
Az Appium 2 Project egy Java-alapú, Appium 2-vel készült tesztautomatizálási keretrendszer, amely natív és webes mobilalkalmazások tesztelését támogatja helyi és felhőalapú (BrowserStack) környezetben.
- A projektről
- Főbb jellemzők és technikai megoldások
- Felhasznált technológiák
- Tesztelt alkalmazások
- Telepítés és előkészületek
- Használat és tesztek futtatása
- Screenshots and videos of the tests
A projekt tanulási célból készült, hogy junior szoftvertesztelőként gyakorolhassam és mélyítsem az ismereteimet a tesztautomatizálás, különösen a mobil- és webalapú rendszerek tesztelésének területén. Olyan tesztkeretrendszert szerettem volna létrehozni, amely felépítésében és működésében hasonlít a munkahelyi környezetekben használt megoldásokhoz.
A keretrendszert teljes egészében a nulláról építettem fel. A fő technológiák: Java, Appium 2, Selenium, TestNG és Log4j. A rendszer képes automatikusan kezelni az Appium szervert, naplókat és riportokat generálni (Extent Reports, valamint HTML formátumú email-riport), illetve hiba esetén képernyőmentéseket készíteni. Ezeket képes Netlify-ra feltölteni és SendGrid API segítségével emailben továbbítani. Bár ezen funkciók egy valós CI/CD környezetben sokszor központilag vannak kezelve, célom az volt, hogy kézzel implementálva is megismerjem működésüket és ezáltal újabb Java könyvtárakat, technikákat is elsajátítsak.
A tesztek adatvezérelt módon működnek, a bemeneti adatok JSON fájlokból érkeznek. A tervezés során kiemelt szempont volt a modularitás, az újrafelhasználhatóság és a könnyű karbantarthatóság. A kódminőség javításában a PMD és a SpotBugs eszközök is szerepet kaptak.
Természetesen számtalan fejlesztési és finomítási lehetőség van még. A következő céljaim közé tartozik a párhuzamos tesztfuttatás, valamint a CI/CD integráció, például Jenkins segítségével.
A tesztelést valós Android eszközön (Xiaomi Redmi Note 8T - Android 11), valamint BrowserStack felhőszolgáltatásban végeztem, melyet fentebb videókban be is mutatok.
A projekt a modern szoftverfejlesztési és tesztautomatizálási best practice-eket követi:
- Page Object Model (POM): Az UI-elemek és a velük végzett műveletek elkülönülnek a tesztlogikától, így tiszta, jól karbantartható kód jön létre.
- Adatvezérelt konfiguráció: A driverképességek (capabilities), környezeti beállítások és tesztadatok külső
JSONés.propertiesfájlokban találhatók. Ez lehetővé teszi a tesztkörnyezet módosítását a Java-kód megváltoztatása nélkül. - Factory és Builder tervezési minták:
DriverFactory: Egy központi "gyár", amely különféleAndroidDriverpéldányokat hoz létre (natív/web, lokális/cloud).OptionsBuilderosztályok: A komplex Appium capabilities objektumok dinamikus és olvasható összeállításáért felelősek.
- POJO és enum osztályok a struktúrált adatreprezentációhoz:
- A rendszer
POJOosztályokat (pl.AppiumOptionsData) használ a JSON konfigurációk és tesztadatok beolvasására, Jackson segítségével. Ez típuskontrollt és jobb olvashatóságot biztosít a nyersMap-ekkel szemben. - Az
enum-ok a fix, előre definiált értékek (pl. futtatási környezetek) biztonságos kezelését segítik, megelőzve az elgépelésből eredő hibákat.
- A rendszer
- Lépésekre, asszerciókra és providerekre tagolt logika:
- A tesztek jól definiált rétegekre bonthatók. A Page Object osztályok tartalmazzák az újrafelhasználható, üzleti szintű lépéseket (pl.
login()), míg a tesztmetódusok ezek meghívásáért és az asszertálásért felelősek. - A DataProvider osztályok segítségével támogatott az adatvezérelt (data-driven) tesztelés.
- A tesztek jól definiált rétegekre bonthatók. A Page Object osztályok tartalmazzák az újrafelhasználható, üzleti szintű lépéseket (pl.
- Környezetfüggő futtatás: Egyetlen konfigurációs kapcsolóval válthatunk a lokális (valós eszköz vagy emulátor) és a felhőalapú (BrowserStack) futtatás között.
- Programozott szerverkezelés: Az
AppiumServerManagerautomatikusan képes elindítani/leállítani az Appium szervert, így manuális beavatkozás nem szükséges. - Részletes riportálás: A rendszer két párhuzamos riportálási mechanizmust kínál:
- ExtentReports: Interaktív, vizuális HTML-riport, hibák esetén képernyőmentéssel.
- Saját e-mailes riportküldés: A SendGrid API segítségével HTML-formátumú értesítés küldhető, amely független bármely CI/CD rendszertől.
- Időbélyeges logolás fájlba (
logback): ALog4jlogolórendszer minden tesztfutáshoz és szerverindításhoz külön, időbélyeges logfájlt hoz létre, így elkerülhető a logfelülírás, és egyszerűbb a hibakeresés. A logolás szintje és célhelye a tesztfuttatáshoz alog4j.properties, az Appium serverhez aconfig.propertiesfájlban állítható. - Hibakezelés saját kivételosztályokkal: A keretrendszer több egyedi
RuntimeException-leszármazott osztályt definiál (pl.ConfigurationException,JsonReadException,LogFileException), amelyek aAppiumProjectExceptionősosztályból származnak. Ezek az osztályok segítenek kontextusfüggőbb, jól értelmezhető hibakezelés kialakításában, és megkönnyítik a hibák naplózását és nyomon követését. - DRY (Don't Repeat Yourself) alapú refaktorálás: A projekt teljes egészében a DRY-elv mentén épül fel. A gyakran ismétlődő műveletek – mint például a driverkezelés, konfigurációolvasás vagy gyakori UI-interakciók – központosított, újrafelhasználható komponensekben vannak elhelyezve. Ez jelentősen csökkenti a kódismétlést és növeli a hosszú távú karbantarthatóságot.
A projekt a következő fő technológiák és könyvtárak legfrissebb vagy közeli verzióit használja:
- Java 22.0
- Maven 3.9.9
- Appium 2.19.0
- Appium Java Client 9.2.2
- Selenium 4.22.0
- TestNG 7.10.2
- Log4j 2.24.0
- Jackson 2.19
- Extent reports 5.1.2
- Sendgrid 4.10.3 (email küldés)
- Netlify-CLI 18.0.4 (fájlfeltöltés szerverre)
- SauceLabs Swag Labs (natív) app (MyDemoAppRN.1.3.0.build-244)
- Battery Alarm (natív) app (v76) (Battery Alarm webpage)
- CURA Healthcare Service (web) app (Katalon demo webpage)
- Chrome version: 137.0.7151.89
- Java Development Kit (JDK) 22 vagy újabb
- Apache Maven – a projekt buildeléséhez és a tesztek futtatásához
- Node.js és npm – az Appium telepítéséhez és futtatásához
- Appium 2 – globálisan telepítve (
npm install -g appium@next) - Android SDK – javasolt az Android Studio-val együtt telepíteni, amely biztosítja a szükséges eszközöket és AVD-kezelőt is
- Külső szolgáltatások regisztrációja és konfigurálása:
- Sendgrid – e-mail alapú tesztriportok küldéséhez. Konfigurációs fájl:
src/main/resources/emailsendingdata/sendgrid_account.json - Netlify – a teszt reportokban szereplő fájlok (pl. screenshotok) nyilvános eléréséhez egy egyszerű Netlify-fiók és deploy szükséges
- BrowserStack – felhőalapú eszközparkban való tesztfuttatáshoz. Beállítási fájlok:
src/test/resources/testdatafiles/options/browserstack/
- Sendgrid – e-mail alapú tesztriportok küldéséhez. Konfigurációs fájl:
- Futtatási környezet és böngésző: Az
src/main/resources/config.propertiesfájlban adhatók meg az alábbi beállítások:run.environment: A tesztek futtatási környezete. Lehetséges értékek:local(helyi gépen) vagycloud(BrowserStack).browser.type: A webes tesztekhez használt böngésző. Lehetséges értékek:chromevagyfirefox.
- Driver képességek (capabilities): A platform- és környezetspecifikus Appium-beállítások külön JSON-fájlokban találhatók a következő útvonalon:
src/test/resources/testdatafiles/options/appium/.
A keretrendszer a TestNG tesztkeretrendszert használja a tesztek konfigurálásához és futtatásához, kihasználva annak fejlett vezérlési lehetőségeit.
- Test Suite-ok: A különféle tesztelési célokra (pl. gyors ellenőrzés, teljes regresszió) előre definiált futtatási csomagok találhatók az
src/test/resources/testng-configs/mappában. Ezek lehetővé teszik, hogy csak a releváns teszteket futtassuk, optimalizálva az időt és az erőforrásokat.smoke-tests.xml: Alapfunkcionalitást ellenőrző, gyors futású tesztek.regression-tests.xml: A rendszer teljes körű funkcionális lefedettségét biztosító tesztcsomag.
- TestNG-csoportok (groups): A tesztek
@Test(groups = {"smoke"})annotációval logikailag elkülöníthetők. - Adatvezérelt tesztelés (@DataProvider): A keretrendszer támogatja a data-driven testing megközelítést. A CURA H.S. alkalmazás
DataProviderTestsosztálya példát mutat arra, hogyan olvashatók be a tesztadatok (felhasználónév, jelszó) külső JSON fájlból (asrc/test/resources/testdatafiles/testinputs/mappából). ACuraLoginTestDataProviderosztály különválasztja az adatszolgáltatást a tesztlogikától, így ugyanaz a teszteset több bemeneti kombinációval is végrehajtható. - Prioritás és függőségek: A
@Test(priority = ...)annotáció lehetővé teszi a tesztek futtatási sorrendjének megadását, ami különösen hasznos összetett, egymásra épülő felhasználói folyamatok tesztelésekor.
A tesztek futtatása kétféleképpen történhet – mindkét esetben a testng.xml suite-fájlok képezik az alapot.
A pom.xml fájlban konfigurált Maven Surefire Plugin gondoskodik a tesztek futtatásáról. A következő parancsokat a projekt gyökérkönyvtárából kell kiadni:
-
Alapértelmezett suite futtatása (a
pom.xmlalapján):mvn clean test -
Konkrét suite futtatása a
-Dsurefire.suiteXmlFilesparaméterrel:mvn clean test -Dsurefire.suiteXmlFiles=src/test/resources/testng-configs/testng-smoke.xml
Bármely modern Java IDE (pl. IntelliJ IDEA vagy Eclipse) támogatja a TestNG-t, így grafikus felületen keresztül is indíthatók a tesztek, egyéni test suite-ok vagy akár egyes metódusok szintjén.
Licenc: Ez a projekt az MIT-licenc alatt érhető el. Készítette: Szabolcs Szigli