Skip to content

A TestNG-based UI testing framework for SDET training. Demonstrates TestNG annotations, parallel testing, cross-browser testing, logging with Log4j2, and structured reporting. Designed to help students strengthen automation testing skills with practical examples and configuration.

License

Notifications You must be signed in to change notification settings

cihat-kose/testng-practice-lessons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

75 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TestNG Practice Lessons

Java TestNG Selenium Log4j2 Maven

πŸ’‘ Introduction

Welcome to the testng-practice-lessons repository! This project is designed for SDET students to reinforce their knowledge through practical lessons. It demonstrates how to perform test automation using TestNG with TestNG-specific features like annotations, parallel execution, and data providers.

Table of Contents

πŸ“₯ Installation

Cloning the Repository

To install TestNGCurrent, clone the repository to your local machine:

git clone https://github.com/cihat-kose/testng-practice-lessons.git

Importing into IntelliJ IDEA from VCS

  1. Open IntelliJ IDEA.
  2. Go to File > New > Project from Version Control.
  3. In the dialog, select Git and enter the repository URL: https://github.com/cihat-kose/testng-practice-lessons.git.
  4. Click Clone.

Adding Dependencies from Maven

  1. Open IntelliJ IDEA.
  2. Navigate to File > Project Structure > Libraries.
  3. Click on the + icon and select From Maven.
  4. In the dialog, search for the necessary libraries using the Maven coordinates:
    • org.apache.logging.log4j:log4j-api:2.20.0
    • org.apache.logging.log4j:log4j-core:2.20.0
    • commons-io:commons-io:2.18.0
    • org.seleniumhq.selenium:selenium-java:4.32.0
    • org.slf4j:slf4j-nop:2.0.17
    • org.testng:testng:7.11.0
  5. Click OK to add the selected libraries.

For each library, you can also use a higher version if available.

βš™οΈ Usage

Ensure that you have the necessary dependencies installed and navigate to the src directory to set up and execute the test cases.

1. Running from XML File

Run your tests from any TestNG XML file by following these steps:

# From IntelliJ IDEA or Eclipse
Right-click on any XML file (e.g., 'cross-browser-test.xml') and select 'Run'.

# To run from command line with Maven
mvn test -DsuiteXmlFile=your-test-suite.xml

2. Running Test Classes Directly

You can directly run test classes annotated with TestNG:

# Right-click on the class in IntelliJ IDEA and select 'Run ClassName'.

# To run all test classes with Maven
mvn test

✨ Features

  • Sorting: Organize tests in a specific order.
  • Annotations: Use TestNG's rich set of annotations to define test methods.
  • Enable/Disable: Enable or disable tests dynamically.
  • Assertions: Utilize TestNG assertions to validate test outcomes.
  • Dependency Management: Manage test method dependencies.
  • Groups: Group tests for selective execution.
  • Cross Browser Testing: Execute tests across multiple browsers.
  • Parallel Testing: Run tests in parallel to save time.
  • XML Configuration: Configure test suites using testng.xml.
  • Data Providers: Supply data to test methods.
  • Parameterized Tests: Run the same test with different parameters.
  • Page Object Model (POM): Implement POM for cleaner code.
  • HTML Reporting: Generate HTML reports for test results.
  • Logging: Integrated logging using Log4j2 for tracking and debugging test execution.

πŸ“¦ Dependencies

Dependency Version Link
Java 21+ Java
TestNG 7.11.0 TestNG
Selenium WebDriver 4.32.0 Selenium
Log4j2 2.20.0 Log4j2 API, Log4j2 Core
Commons IO 2.18.0 Commons IO
SLF4J NOP 2.0.17 SLF4J NOP

πŸ”§ Configuration

Configuration details can be found in the testng.xml file and other relevant configuration files within the project. Log4j2 configuration is set up in the log4j2.xml file to provide detailed logging.

Log4j2 Integration

The project uses Log4j2 for logging purposes. Ensure the necessary dependencies are included in your project and the log4j2.xml file is correctly configured for detailed logging. Logging is crucial for tracking and debugging test execution; BaseDriver utilizes Log4j2 to log test methods' start, end, and results.

πŸ“š Documentation

Detailed documentation is available in the repository's README.md file and inline comments within the codebase. Here are some tools and programs used:

πŸ’‘ Examples

This project includes several examples designed to demonstrate TestNG's capabilities, including:

Annotations

  • @Test: Define individual test methods.
  • @BeforeClass/@AfterClass: Setup and teardown methods for test classes.
  • @BeforeMethod/@AfterMethod: Run methods before and after each test method.

Parallel Execution

  • Parallel Execution in XML: Configure parallel execution in the testng.xml file for faster test execution.

Data Providers

  • Data Providers: Pass data to test methods dynamically using the @DataProvider annotation.

Cross Browser Testing

  • Browser Setup: Set up tests to run on multiple browsers using WebDriver.

πŸ› οΈ Troubleshooting

If you encounter any issues:

  • Ensure that TestNG and Selenium WebDriver are properly installed and operational.
  • Verify that your Java environment is correctly set up for TestNG and other dependencies.
  • Check that your IntelliJ IDEA and other development tools are configured according to the project's requirements.
  • If problems persist, check your Maven configurations to ensure all necessary dependencies are correctly included.

For additional help, please open an issue in the GitHub repository.

πŸ‘₯ Contributors

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Commit your changes (git commit -m 'Add new feature').
  4. Push to the branch (git push origin feature-branch).
  5. Create a Pull Request.

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

For more information on how to get started, visit the TestNG Practice Lessons.

About

A TestNG-based UI testing framework for SDET training. Demonstrates TestNG annotations, parallel testing, cross-browser testing, logging with Log4j2, and structured reporting. Designed to help students strengthen automation testing skills with practical examples and configuration.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy