Integrate Optimus to your existing TestNg project
These are high level steps that should help you integrate Optimus to your exiting framework. Incase you face any hurdle kindly reach out to optimus@testvagrant.com for support.
Step 1
Update your “Gradle / Maven” file with below dependencies
Gradle:
dependencies {
implementation 'com.testvagrant.optimuscloud:testng-dashboard:1.0.0'
compile group: 'org.testng', name: 'testng', version: '7.0.0'
implementation 'com.testvagrant.optimuscloud:java-client:1.0.0'
}
Maven:
<dependencies>
<dependency>
<groupId>com.testvagrant.optimuscloud</groupId>
<artifactId>optimus-monitor</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.testvagrant.optimuscloud</groupId>
<artifactId>java-client</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Step 2
Update your @BeforeMethod with below changes
- Save
MobileDriverDetailstoITestContext
Step 2.1
Add ITextContext parameter to your @BeforeMethod definition.
@BeforeMethod
public void setup(ITestContext iTestContext){
}
Step 2.2
Create mobile driver using OptimusCloudDriver
@BeforeMethod
public void setup(ITestContext iTestContext){
MobileDriverDetails mobileDriverDetails = new OptimusCloudDriver().createDriver(desiredCapabilities);
MobileDriver mobileDriver = mobileDriverDetails.getMobileDriver();
}
Step 2.3
Save MobileDriverDetails to ITestContext
@BeforeMethod
public void setup(ITestContext iTestContext){
MobileDriverDetails mobileDriverDetails = new OptimusCloudDriver().createDriver(desiredCapabilities);
MobileDriver mobileDriver = mobileDriverDetails.getMobileDriver();
iTestContext.setAttribute(OptimusCloudConstants.MOBILE_DRIVER, mobileDriverDetails);
}
Step 3
Add below listeners to your testng.xml or build.gradle
com.testvagrant.optimuscloud.dashboard.testng.listener.OptimusSuiteListenercom.testvagrant.optimuscloud.dashboard.testng.listener.OptimusTestListener
Eg: build.gradle
task runTests(type: Test) {
outputs.upToDateWhen {false}
useTestNG() {
testLogging.showStandardStreams = true
testLogging.showStandardStreams = true
reports.html.enabled = false
useDefaultListeners = true
parallel 'methods'
listeners.add "com.testvagrant.optimuscloud.dashboard.testng.listener.OptimusSuiteListener"
listeners.add "com.testvagrant.optimuscloud.dashboard.testng.listener.OptimusTestListener"
}
}
Eg: testng.xml
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" >
<suite name="Suite1" verbose="1" >
<listeners>
<listener class-name="com.testvagrant.optimuscloud.dashboard.testng.listener.OptimusSuiteListener" />
<listener class-name="com.testvagrant.optimuscloud.dashboard.testng.listener.OptimusTestListener" />
</listeners>
</suite>
Step 4
Run tests using testng.xml or by running gradle runTests
Step 5
Navigate to http://localhost:9901 and login with credentials creds: u: admin, p: C0mplexPwd. You will be able to see optimus dashboard.
Build History

TestDetails Report

Non Functional Report
