Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

# Binary files should be left untouched
*.jar binary

18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build

# Ignore Allure results (test artifacts)
allure-results/
**/allure-results/

# Ignore IDE files
.idea/
.vscode/
*.iml

# Ignore OS generated files
.DS_Store
Thumbs.db
83 changes: 82 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,82 @@
# appium-autotest
# Appium Autotest

A Java-based automation testing framework using Appium for mobile application testing.

## Project Structure

This is a Gradle-based Java project with the following key dependencies:

### Dependencies

- **Appium Java Client** (9.3.0) - For mobile automation testing
- **JUnit 5 (Jupiter)** (5.12.1) - Modern testing framework
- **SLF4J** (2.0.13) - Logging framework
- **Allure** (2.29.0) - Test reporting and visualization
- **Guava** (33.4.6-jre) - Google's core libraries for Java

### Project Layout

```
app/
├── src/
│ ├── main/java/ # Application source code
│ └── test/java/ # Test source code
├── build.gradle # Build configuration
└── build/ # Build outputs and reports
```

## Building the Project

To build the project:

```bash
./gradlew build
```

## Running Tests

To run all tests:

```bash
./gradlew test
```

To run tests with detailed output:

```bash
./gradlew test --info
```

## Test Reports

After running tests, you can find the reports in:

- **JUnit Reports**: `app/build/reports/tests/test/index.html`
- **Allure Reports**: Generate with `./gradlew allureReport` (reports in `app/build/reports/allure-report/`)

## Sample Tests

The project includes sample tests that verify:

1. **Appium Setup** - Validates Appium Java Client integration
2. **Logging** - Demonstrates SLF4J logging functionality
3. **Allure Reporting** - Shows Allure annotations usage
4. **JUnit 5 Features** - Modern testing capabilities

## Requirements

- Java 17 or higher
- Gradle 9.0.0 or higher (wrapper included)

## Getting Started

1. Clone the repository
2. Run `./gradlew build` to build the project
3. Run `./gradlew test` to execute tests
4. View test reports in `app/build/reports/tests/test/index.html`

## Configuration

- **Gradle Properties**: See `gradle.properties` for build configuration
- **Dependencies**: Managed in `gradle/libs.versions.toml`
- **Build Script**: Main configuration in `app/build.gradle`
52 changes: 52 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/9.0.0/userguide/building_java_projects.html in the Gradle documentation.
*/

plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

dependencies {
// Use JUnit Jupiter for testing.
testImplementation libs.junit.jupiter
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

// Appium Java Client for mobile automation
testImplementation libs.appium.java.client

// SLF4J for logging
implementation libs.slf4j.api
implementation libs.slf4j.simple

// Allure for test reporting
testImplementation libs.allure.junit5

// This dependency is used by the application.
implementation libs.guava
}

// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

application {
// Define the main class for the application.
mainClass = 'org.example.App'
}

tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
14 changes: 14 additions & 0 deletions app/src/main/java/org/example/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This source file was generated by the Gradle 'init' task
*/
package org.example;

public class App {
public String getGreeting() {
return "Hello World!";
}

public static void main(String[] args) {
System.out.println(new App().getGreeting());
}
}
14 changes: 14 additions & 0 deletions app/src/test/java/org/example/AppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This source file was generated by the Gradle 'init' task
*/
package org.example;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

class AppTest {
@Test void appHasAGreeting() {
App classUnderTest = new App();
assertNotNull(classUnderTest.getGreeting(), "app should have a greeting");
}
}
103 changes: 103 additions & 0 deletions app/src/test/java/org/example/AppiumDriverExampleTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Example of a basic Appium test structure
*/
package org.example;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.remote.options.BaseOptions;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.MalformedURLException;
import java.net.URL;

import static org.junit.jupiter.api.Assertions.*;

@Feature("Appium Driver Examples")
class AppiumDriverExampleTest {

private static final Logger logger = LoggerFactory.getLogger(AppiumDriverExampleTest.class);

@Test
@DisplayName("Verify Android Driver can be instantiated (without connection)")
@Description("Example showing Android driver setup structure")
void testAndroidDriverStructure() {
logger.info("Testing Android Driver structure");

// This test demonstrates how to structure Android driver setup
// Note: This doesn't actually connect to a device/emulator

BaseOptions options = new BaseOptions();
options.setCapability("platformName", "Android");
options.setCapability("appium:deviceName", "Test Device");
options.setCapability("appium:app", "/path/to/app.apk");

// Verify we can create the options object
assertNotNull(options);
assertNotNull(options.asMap());
assertTrue(options.asMap().size() > 0);

logger.info("Android Driver structure test passed");
}

@Test
@DisplayName("Verify iOS Driver can be instantiated (without connection)")
@Description("Example showing iOS driver setup structure")
void testIOSDriverStructure() {
logger.info("Testing iOS Driver structure");

// This test demonstrates how to structure iOS driver setup
// Note: This doesn't actually connect to a device/simulator

BaseOptions options = new BaseOptions();
options.setCapability("platformName", "iOS");
options.setCapability("appium:deviceName", "iPhone Simulator");
options.setCapability("appium:app", "/path/to/app.app");

// Verify we can create the options object
assertNotNull(options);
assertNotNull(options.asMap());
assertTrue(options.asMap().size() > 0);

logger.info("iOS Driver structure test passed");
}

@Test
@DisplayName("Verify Appium server URL configuration")
@Description("Example showing Appium server URL setup")
void testAppiumServerURL() throws MalformedURLException {
logger.info("Testing Appium server URL configuration");

// Standard Appium server URL
String serverURL = "http://127.0.0.1:4723";
URL appiumServerURL = new URL(serverURL);

assertNotNull(appiumServerURL);
assertEquals("127.0.0.1", appiumServerURL.getHost());
assertEquals(4723, appiumServerURL.getPort());
assertEquals("http", appiumServerURL.getProtocol());

logger.info("Appium server URL configuration test passed");
}

@Test
@DisplayName("Verify driver class availability")
@Description("Verify that all necessary Appium driver classes are available")
void testDriverClassAvailability() {
logger.info("Testing driver class availability");

// Verify base classes are available
assertNotNull(AppiumDriver.class);
assertNotNull(AndroidDriver.class);
assertNotNull(IOSDriver.class);
assertNotNull(BaseOptions.class);

logger.info("All driver classes are available");
}
}
86 changes: 86 additions & 0 deletions app/src/test/java/org/example/AppiumSetupTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Sample test to verify all dependencies are working correctly
*/
package org.example;

import io.appium.java_client.AppiumDriver;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.junit.jupiter.api.Assertions.*;

@Feature("Appium Setup Verification")
class AppiumSetupTest {

private static final Logger logger = LoggerFactory.getLogger(AppiumSetupTest.class);

@Test
@DisplayName("Verify Appium Driver can be imported")
@Description("This test verifies that Appium Java Client dependency is correctly configured")
@Story("Dependency verification")
void testAppiumDriverImport() {
logger.info("Testing Appium Driver import");

// Test that we can reference AppiumDriver class (dependency is available)
Class<?> appiumDriverClass = AppiumDriver.class;
assertNotNull(appiumDriverClass, "AppiumDriver class should be available");
assertEquals("AppiumDriver", appiumDriverClass.getSimpleName());

logger.info("Appium Driver import test passed");
}

@Test
@DisplayName("Verify SLF4J logging is working")
@Description("This test verifies that SLF4J logging dependency is correctly configured")
@Story("Logging verification")
void testSLF4JLogging() {
logger.info("Testing SLF4J logging functionality");

// Test that logger is working
assertNotNull(logger, "Logger should be initialized");
assertEquals("org.example.AppiumSetupTest", logger.getName());

// Test different log levels
logger.debug("Debug message");
logger.info("Info message");
logger.warn("Warning message");
logger.error("Error message");

logger.info("SLF4J logging test passed");
}

@Test
@DisplayName("Verify Allure annotations are working")
@Description("This test verifies that Allure reporting dependency is correctly configured")
@Story("Reporting verification")
void testAllureAnnotations() {
logger.info("Testing Allure annotations");

// If this test runs without errors, it means Allure annotations are working
assertTrue(true, "Allure annotations should be available and functional");

logger.info("Allure annotations test passed");
}

@Test
@DisplayName("Verify JUnit 5 is working")
@Description("This test verifies that JUnit 5 (Jupiter) is correctly configured")
@Story("Testing framework verification")
void testJUnit5Features() {
logger.info("Testing JUnit 5 features");

// Test basic assertions
assertTrue(true);
assertFalse(false);
assertEquals("expected", "expected");
assertNotNull(logger);

// Test that we can use modern JUnit 5 features like DisplayName
logger.info("JUnit 5 test passed");
}
}
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

org.gradle.configuration-cache=true

Loading