Child pages
  • @After cucumber tag does not work in jenkins

Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata


Hi All, 

The cucumber tag with @After in Test Listener in Katalon Studio works well in local system, but when executed in Jenkins it does not work. I have used it for taking Screenshots on failed scenarios and embed it in the report. It does not even enter the function with the @After tag.

Kindly Help.

Code:


@After
def public void endTest(Scenario scenario){

println "####### Entered to take Screenshot ############3"
WebDriver driver = DriverFactory.getWebDriver()
if(scenario.isFailed()){
println "############ Entered if before screenshot ############"
Screenshot fpScreenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000))
.takeScreenshot(driver);

BufferedImage originalImage = fpScreenshot.getImage();

ByteArrayOutputStream baos = new ByteArrayOutputStream()
ImageIO.write(originalImage, "png", baos);

baos.flush();

baos.toByteArray()
println "Before Embed"
scenario.embed(baos.toByteArray(), "image/png")

println "After Embed"
}
}


Kindly help.   Thanks