use of io.cucumber.java.After in project syndesis-qe by syndesisio.
the class RestTestHooks method afterTest.
@After
public void afterTest() {
stepStorage.flushStepDefinitions();
log.debug("Flushed steps from steps storage");
SampleDbConnectionManager.closeConnections();
if (TestConfiguration.isDeloreanEnvironment()) {
// delete all integrations and connections after the test. Only for Delorean since it doesn't support TEST_SUPPORT env
List<Integration> integrations = integrationsEndpoint.list();
for (Integration integration : integrations) {
integrationsEndpoint.delete(integration.getId().get());
}
List<Connection> connections = connectionsEndpoint.list();
for (Connection connection : connections) {
if (SyndesisDB.DEFAULT_PSQL_CONNECTION_ORIGINAL.equals(connection.getName()) || SyndesisDB.DEFAULT_PSQL_CONNECTION_BACKUP.equals(connection.getName()) || // for default connections (Webhook, Log, Flow, Timer, Api Provider etc.) We don't want to delete them
connection.getTags().isEmpty()) {
continue;
}
connectionsEndpoint.delete(connection.getId().get());
}
}
}
use of io.cucumber.java.After in project syndesis-qe by syndesisio.
the class IssueHooks method checkIssues.
/**
* This hook checks and reports status of linked github and ENTESB Jira issues.
* <p>
* Each failed scenario is checked if it contains a tag in the form @gh-<issue-number> or @ENTESB-<issue-number>.
* If it does, Jira or GitHub and ZenHub are queried for the status of each issue and a summary is written into log and cucumber report.
* <p>
* For the purposes of this report, the following issue states are recognized:
* <ol>
* <li>Open - an issue that was reported and not yet fixed</li>
* <li>Done - an issue that was reported and supposedly fixed</li>
* <li>Closed - and issue that was fixed and verified by QE</li>
* </ol>
* <p>
* <p>
* No effort is made to reason about the impact of the found issues (e.g. is it ok that a test fails if there's one open and one done issue?).
* Also, this hook completely ignores passed tests (i.e. nothing happens when a tests with open issues passes).
*
* @param scenario scenario
*/
@After
public void checkIssues(Scenario scenario) {
if (!scenario.isFailed()) {
return;
}
List<SimpleIssue> issues = getAllIssues(scenario);
if (issues.isEmpty()) {
IssueHooksUtils.logError(scenario, "############ No GitHub or Jira issue annotations found ############");
return;
}
try {
List<SimpleIssue> openIssues = new ArrayList<>();
List<SimpleIssue> doneIssues = new ArrayList<>();
List<SimpleIssue> closedIssues = new ArrayList<>();
for (SimpleIssue issue : issues) {
switch(issue.getState()) {
case DONE:
doneIssues.add(issue);
break;
case OPEN:
openIssues.add(issue);
break;
case CLOSED:
closedIssues.add(issue);
break;
}
}
IssueHooksUtils.logError(scenario, "############ FAILED PROBABLY DUE TO: ################");
IssueHooksUtils.logError(scenario, "######## DONE issues ########");
IssueHooks.logIssues(scenario, doneIssues);
IssueHooksUtils.logError(scenario, "######## CLOSED issues ########");
IssueHooks.logIssues(scenario, closedIssues);
IssueHooksUtils.logError(scenario, "######## OPEN issues ########");
IssueHooks.logIssues(scenario, openIssues);
embedIssues(scenario, issues);
} catch (Exception e) {
log.error("Error while processing GH & Jira issues", e);
scenario.attach("Error while processing GH & Jira issues".getBytes(), "text/plain", "ErrorMessage");
e.printStackTrace();
}
}
Aggregations