Created
June 30, 2022 05:58
-
-
Save Watcher24/3853a2325696f4989a846d76e8f6df25 to your computer and use it in GitHub Desktop.
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 it.info.magnolia.test.cucumber.ui; | |
import static io.cucumber.core.options.Constants.GLUE_PROPERTY_NAME; | |
import info.magnolia.test.selenium.CucumberUiTestHelper; | |
import io.cucumber.java.After; | |
import io.cucumber.java.Before; | |
import io.cucumber.java.Scenario; | |
import org.junit.platform.suite.api.ConfigurationParameter; | |
import org.junit.platform.suite.api.IncludeEngines; | |
import org.junit.platform.suite.api.SelectClasspathResource; | |
import org.junit.platform.suite.api.Suite; | |
import com.codeborne.selenide.Selenide; | |
/** | |
* Runs / triggers cucumber to test the scenarios of the corresponding features. | |
*/ | |
@Suite | |
@IncludeEngines("cucumber") | |
@SelectClasspathResource("it/info/magnolia/test/cucumber/ui/admincentral.feature") | |
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "it.info.magnolia.test.cucumber.ui") | |
public class AdminCentral_RunScenarios { | |
private CucumberUiTestHelper cucumberUiTestHelper; | |
private String featureName = "Admincentral"; | |
private String testIdentifier; | |
/** | |
* Executed before each scenario of the linked scenarios. | |
*/ | |
@Before | |
public void setUp(Scenario scenario) { | |
this.cucumberUiTestHelper = new CucumberUiTestHelper(); | |
testIdentifier = featureName + "-" + scenario.getName(); | |
cucumberUiTestHelper.vncRecordingHelper().start(testIdentifier); | |
} | |
/** | |
* Executed after each scenario of the linked scenarios, also if some steps fail. | |
*/ | |
@After | |
public void tearDown(Scenario scenario){ | |
Selenide.closeWebDriver(); | |
if(scenario.isFailed()){ | |
// TODO ... we should fetch the real Throwable ... but | |
// ugly way: via reflection, see https://stackoverflow.com/questions/42542557/how-to-get-the-exception-that-was-thrown-when-a-cucumber-test-failed-in-java | |
// cumbersome way: see via Listener, see https://github.com/cucumber/cucumber-jvm/issues/1901 | |
// anyhow, not totally sure we need the Throwable. Depends on what goes into jenkins-log | |
cucumberUiTestHelper.vncRecordingHelper().failed(testIdentifier, new Throwable("Not sure what happend")); | |
}else{ | |
cucumberUiTestHelper.vncRecordingHelper().succeeded(testIdentifier); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment