Last active
March 11, 2021 11:12
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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