Skip to content

Instantly share code, notes, and snippets.

@rookieInTraining
Last active March 11, 2021 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rookieInTraining/8fae4d459514a299925d06a59090c832 to your computer and use it in GitHub Desktop.
Save rookieInTraining/8fae4d459514a299925d06a59090c832 to your computer and use it in GitHub Desktop.
Gist for the code used to reproduce the skip exception's throwable missing in ITestResult
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
ext.libraries = [
// Testing Framework
testng : 'org.testng:testng:7.4.0',
//For Browsers and Devices
selenium : 'org.seleniumhq.selenium:selenium-java:4.0.0-beta-1',
webdrivermanager : 'io.github.bonigarcia:webdrivermanager:4.0.0'
]
dependencies {
testCompile libraries.testng
testCompile libraries.selenium
testCompile libraries.webdrivermanager
}
test {
testLogging {
exceptionFormat = 'full'
events "STARTED", "PASSED", "FAILED", "SKIPPED"
}
useTestNG {
}
}
package com.sample.tests;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestNGSeleniumSkipTest {
WebDriver driver;
@BeforeMethod(alwaysRun = true)
public void init() {
WebDriverManager.edgedriver().setup();
driver = new EdgeDriver(new EdgeOptions());
driver.get(""); // Marked intentionally in order to skip the test
}
@Test(testName = "Sample Test")
public void sampleTestOne() {
System.out.println(driver.getCurrentUrl());
}
@AfterMethod(alwaysRun = true)
public void teardown(ITestResult result) {
System.out.println(result.getThrowable().getMessage()); // LoC where I get a NullPointerException
driver.quit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment