CloudBeat Docs
HomeRequest a DemoContactSign In
  • What is CloudBeat?
  • Get Started
    • Quick Start
  • SUPPORTED FRAMEWORKS
    • Java JUnit
    • .NET MSTest
    • Playwright (JS/TS)
  • Fundamentals
    • Creating Projects
    • Creating Environments
    • Creating Tests Cases
    • Running Tests Cases
    • Creating Tests Suites
    • Running Tests Suites
    • Creating Releases
    • Adding Apps
  • Sample Projects
    • Introduction to Cloudbeat sample projects
    • Oxygen Cucumber project
    • Oxygen project
    • TestNG project
  • Features
    • Integrations
      • CI/CD Pipeline
        • Jenkins
        • Azure DevOps
      • Cloud Providers
        • Genymotion
        • Applitools
        • Perfecto
    • Supported Frameworks
    • Data-Driven Testing
      • DDT - Oxygen Framework
  • CloudBeat Synthetic
    • What is CloudBeat Synthetic?
    • Creating your first monitor
    • Review general monitor results
    • Review specific monitor dashboard
    • Create SLA
    • Create Reports & Alerts
    • Changing Runtime Setting
    • Run Monitors
    • Maintenance
    • Incidents
    • Full Monitor Test - Example
  • Settings & Administration
    • Managing Notification Groups
    • Managing Permissions
    • Managing Users
    • Managing Account
    • Managing My Profile
  • References
    • Active Runs
    • Test Results
    • Projects
      • Oxygen Project
      • Cucumber + Java Project
      • .Net Project
      • TestNG Project Setup
    • Reports
Powered by GitBook
On this page

Was this helpful?

  1. References
  2. Projects

TestNG Project Setup

Description on how to prepare a TestNG project to be used in CloudBeat

Plugin Integration

Add the cb-framework-plugin-testng plugin to your project. For Maven base projects, this requires adding plugin repository and the plugin dependency.

Gradle based projects are not currently supported .

First add the repository to your pom.xml:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
  </repositories>

And add the plugin dependency itself:

<dependency>
    <groupId>com.github.oxygenhq</groupId>
    <artifactId>cb-framework-plugin-testng</artifactId>
    <version>0.10.1</version>
</dependency>

In addition, if running multiple parallel tests is required, maven surefire plugin with version equal or higher than 2.22.0 should be added to the plugins section:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.22.0</version>
    </plugin>
  </plugins>
</build>

Code Level Integration

Add plugin listener to your test class and extend the test class from CbTestNg

@Listeners(io.cloudbeat.testng.Plugin.class)
public class SeleniumTest extends CbTestNg  {
    
}

Working with Selenium

When using Selenium it might be beneficiary to be able to take browser screenshots in case of failures.

Providing WebDriver instance

import io.cloudbeat.testng.CbTestNg;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class SeleniumTest extends CbTestNg {
    @BeforeClass
    public static void setUp() {
        DesiredCapabilities capabilities = ... // User capabilities                

        // For default web browser initialization based on CloudBeat capabilities
        setupWebDriver();
                
        // For default web browser initialization based on user capabilities and CloudBeat capabilities
        initWebDriver(capabilities);
    
        // For default mobile driver initialization based on CloudBeat capabilities
        setupMobDriver();
        
        // For default web browser initialization based on user capabilities and CloudBeat capabilities
        initMobDriver(capabilities);
        
        //Or just setup your own driver
        WebDriver driver = ... // Your driver initialization
        setupDriver(driver); // Set up driver        

        this.driver; // Created driver
    }
}

Custom steps

In order for CloudBeat to produce nicer repots, startStep and endStep methods can be used to designate test actions

import org.testng.annotations.Test;

public class SeleniumTest extends CbTestNg {
    
    @Test
    public void Test1() {
       startStep("Step");
       startStep("Inner step");
       endStep("Inner step");
       endStep("Step");
    }
}
Previous.Net ProjectNextReports

Last updated 1 year ago

Was this helpful?