package org.mule.modules.jbehave;
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.io.LoadFromRelativeFile;
import org.jbehave.core.junit.JUnitStory;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.reporters.StoryReporterBuilder.Format;
import org.jbehave.core.steps.CandidateSteps;
import org.jbehave.core.steps.InstanceStepsFactory;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
public class TableScenarios extends JUnitStory {
private static final Logger LOG = LoggerFactory.getLogger(TableScenarios.class);
@Override
public Configuration configuration() {
URL storyURL = null;
try {
// This requires you to start Maven from the project directory
storyURL = new URL("file://" + System.getProperty("user.dir")
+ "/src/main/resources/stories/");
} catch (MalformedURLException e) {
LOG.error("Unable to build a well formed URL");
}
return new MostUsefulConfiguration().useStoryLoader(
new LoadFromRelativeFile(storyURL)).useStoryReporterBuilder(
new StoryReporterBuilder().withFormats(Format.HTML));
}
@Override
public List<CandidateSteps> candidateSteps() {
return new InstanceStepsFactory(configuration(), new TableSteps())
.createCandidateSteps();
}
@Override
@Test
public void run() {
try {
super.run();
} catch (Throwable e) {
LOG.error("Unable to run the stories: {}", e.getMessage());
}
}
}