Kihagyás

Test Automation

Test automation is a process where pre-written tests can be executed without human intervention to ensure that the software behaves as expected. Its essence: the machine performs repetitive, structured testing tasks that are time-consuming or error-prone when done manually.

Purpose:

  • stable, repeatable test execution
  • fast feedback on changes
  • prevention of regressions
  • lower long-term testing cost.

Regression tests

A regression test is an automated or manual test that verifies whether a new development, fix, or modification has broken any previously working functionality. Its essence: ensuring that the system continues to work correctly after changes.

Not the purpose of test automation:

  • afully replacing manual testing
  • automating every single test..

Test types: recap

Functional tests: * Unit test * Integration test * End-to-end (E2E) test * API test

Non-functional tests: * Performance test * Load and stress test * Security test

White-box / black-box / gray-box: * White-box: performed with knowledge of code structure * Black-box: only input–output is visible * Gray-box: partial internal knowledge

Good candidates for automation:

  • stable features
  • frequently repeated tests
  • regression tests
  • API tests
  • data-driven checks

Not worth automating:

  • highly changing UI
  • one-time checks
  • exploratory testing
  • tests requiring visual experience.

Test Automation Pyramid

Piramis

Layers of Testing Tools

  • Test framework: (JUnit, PyTest, NUnit, Jest, Mocha, PHPUnit, etc.)
  • Test runner: (maven-surefire, pytest runner, npm test)
  • Automated UI framework: (Selenium, Cypress, Playwright)
  • API testing framework: (REST Assured, Karate, Postman/Newman)
  • CI/CD integration: (GitHub Actions, GitLab CI, Jenkins)

Test Automation Patterns and Methodologies

Page Object Model (POM)

A traditional and well-established architecture for UI tests.

  • Each page is a separate class
  • The class contains locators and actions
  • The test calls only these actions

Goal: clean code, stable tests, easy maintenance.

Data-driven testing

Test data stored in separate files:

  • CSV
  • JSON
  • Excel
  • database

The test repeats automatically with multiple data pairs.

Behavior Driven Development (BDD)

Gherkin

1
2
3
Given  
When  
Then

Tools:

Test Automation Process

  1. Reviewing requirements and specifications
  2. Selecting test cases for automation
  3. Tool selection
  4. Building the framework
  5. Writing the tests
  6. Preparing test data
  7. Integrating into CI/CD
  8. Reporting test results
  9. Maintenance and refactoring

Example API Test (Python: Pytest + Requests)

1
2
3
4
5
6
7
8
import requests

def test_get_user():
    response = requests.get("https://example.com/api/user/1")
    assert response.status_code == 200
    data = response.json()
    assert data["id"] == 1
    assert "name" in data

Example UI Test (Selenium)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
WebDriver driver = new ChromeDriver();
driver.get("https://example.com");

WebElement input = driver.findElement(By.id("username"));
input.sendKeys("testuser");

WebElement btn = driver.findElement(By.id("login"));
btn.click();

Assert.assertEquals("Welcome", driver.getTitle());

driver.quit();

CI/CD Integration (classic model)

Jenkins / GitLab CI:

  • push → automatic build
  • unit tests run
  • application deployed to dev environment
  • integration tests run
  • finally E2E execution
  • report generation (Allure, HTML)

Jenkins

Example report:

Allure

Quality Assurance Metrics

  • Test coverage
  • Defect detection rate
  • Test execution time
  • Test stability
  • Flaky test ratio
  • Mean time to repair (MTTR)

Most Common Test Automation Mistakes

  • Too many E2E tests
  • Unstable locators (e.g., overly long XPath)
  • Trying to fully automate manual tests
  • Automating tests with low business value
  • Mixing test data
  • Ignoring flake errors
  • Incomplete architecture (e.g., missing POM)

Flake

A flake error = a test that behaves non-deterministically: the same test sometimes passes and sometimes fails due to external or hidden factors.

Practical Applications

Swagger

The material related to Swagger is available here.

Playwright

The material related to Playwright is available here.

Selenium

The material related to Selenium is available here.


Utolsó frissítés: 2025-11-30 17:10:14