Skip to content

Commit

Permalink
Upgrade to JBehave 4.3.3 (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
valfirst authored and Yaromudr committed May 24, 2018
1 parent db50009 commit 4fd34ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 91 deletions.
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,15 @@ repositories {

dependencies {
compile "io.appium:java-client:5.0.4"
compile "org.jbehave:jbehave-core:4.1.1"
compile "org.jbehave:jbehave-spring:4.1.1"
compile "org.jbehave:jbehave-core:4.3.3"
compile "org.jbehave:jbehave-spring:4.3.3"
compile "org.projectlombok:lombok:1.16.18"
compile "com.opencsv:opencsv:3.9"
compile "ru.yandex.qatools.allure:allure-junit-adaptor:1.5.4"
compile "org.slf4j:slf4j-api:1.7.25"
testCompile "org.springframework:spring-test:4.3.8.RELEASE"
testCompile "junit:junit:4.12"
testCompile "org.mockito:mockito-core:2.+"
testCompile "de.codecentric:jbehave-junit-runner:1.2.0"
}

loadSettings()
Expand Down
101 changes: 13 additions & 88 deletions src/main/java/ru/colibri/ui/core/reporters/AllureReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.appium.java_client.AppiumDriver;
import org.apache.commons.lang3.StringUtils;
import org.jbehave.core.model.*;
import org.jbehave.core.reporters.NullStoryReporter;
import org.jbehave.core.reporters.StoryReporter;
import org.openqa.selenium.OutputType;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -19,13 +20,14 @@
import java.util.UUID;

@Component
public class AllureReporter extends AllureRunListener implements StoryReporter {
public class AllureReporter extends NullStoryReporter {
private final Map<String, String> suites = new HashMap<>();
@Autowired
private ApplicationContext applicationContext;
private Allure allure = Allure.LIFECYCLE;
private String uid;

@Override
public void beforeStory(Story story, boolean givenStory) {
uid = generateSuiteUid(story);
String path = story.getPath();
Expand All @@ -37,36 +39,38 @@ public void beforeStory(Story story, boolean givenStory) {
allure.fire(event);
}

@Override
public void afterStory(boolean givenStory) {
allure.fire(new TestSuiteFinishedEvent(uid));
}

public void beforeScenario(String scenarioTitle) {
allure.fire(new TestCaseStartedEvent(uid, scenarioTitle));
@Override
public void beforeScenario(Scenario scenario) {
allure.fire(new TestCaseStartedEvent(uid, scenario.getTitle()));
allure.fire(new ClearStepStorageEvent());
}

@Override
public void beforeStep(String step) {
allure.fire(new StepStartedEvent(step).withTitle(step));
}

@Override
public void successful(String step) {
allure.fire(new StepFinishedEvent());
}

@Override
public void ignorable(String step) {
allure.fire(new StepCanceledEvent());
}

@Override
public void comment(String step) {

}

public void notPerformed(String step) {
allure.fire(new StepCanceledEvent());
}

@Override
public void failed(String step, Throwable cause) {
takeScreenshot(step);
allure.fire(new StepFinishedEvent());
Expand All @@ -75,97 +79,18 @@ public void failed(String step, Throwable cause) {

}


@Override
public void pending(String step) {
allure.fire(new StepCanceledEvent());
allure.fire(new TestCasePendingEvent().withMessage("PENDING"));
}


@Override
public void afterScenario() {
allure.fire(new TestCaseFinishedEvent());
}


public void storyNotAllowed(Story story, String filter) {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}


public void storyCancelled(Story story, StoryDuration storyDuration) {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

@Override
public void narrative(Narrative narrative) {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

@Override
public void lifecyle(Lifecycle lifecycle) {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

@Override
public void scenarioNotAllowed(Scenario scenario, String filter) {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

@Override
public void scenarioMeta(Meta meta) {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

@Override
public void givenStories(GivenStories givenStories) {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

@Override
public void givenStories(List<String> storyPaths) {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

@Override
public void beforeExamples(List<String> steps, ExamplesTable table) {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

@Override
public void example(Map<String, String> tableRow) {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

@Override
public void afterExamples() {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

@Override
public void failedOutcomes(String step, OutcomesTable table) {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

@Override
public void restarted(String step, Throwable cause) {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

@Override
public void restartedStory(Story story, Throwable cause) {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

@Override
public void dryRun() {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

@Override
public void pendingMethods(List<String> methods) {
// throw new NotImplementedException("Method not use. Allure doesn't support this");
}

/**
* Generate suite uid.
*
Expand Down

0 comments on commit 4fd34ac

Please sign in to comment.