本文整理汇总了Java中org.jbehave.core.embedder.Embedder类的典型用法代码示例。如果您正苦于以下问题:Java Embedder类的具体用法?Java Embedder怎么用?Java Embedder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Embedder类属于org.jbehave.core.embedder包,在下文中一共展示了Embedder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configuredEmbedder
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
@Override
public Embedder configuredEmbedder() {
StepEventBus.getEventBus().setUniqueSession(true);
Embedder embedder = super.configuredEmbedder();
embedder.useExecutorService(MoreExecutors.sameThreadExecutor());
embedder.configuration().useStepCollector(stepCollector);
embedder.useStepsFactory(new ScanningStepsFactory(embedder
.configuration(), this.getClass(), pages));
embedder.configuration()
.useParameterControls(new ParameterControls()
.useDelimiterNamedParameters(true));
embedder.configuration()
.storyReporterBuilder()
.withReporters(new SatisfyStoryReporter()
, new ConsoleOutput());
embedder.useEmbedderMonitor(new NullEmbedderMonitor());
embedder.useMetaFilters(getSatisfyProperties().getMetaFilters());
return embedder;
}
示例2: runTests
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
@Override
public void runTests(TestPage pageToTest) {
final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
testSummary = new TestSummary();
testSystemListener.testStarted(pageToTest);
try {
Thread.currentThread().setContextClassLoader(classLoader);
Embedder embedder = newEmbedder();
resolveCandidateSteps(pageToTest, embedder);
embedder.runStoriesAsPaths(Collections.singletonList(pageToTest.getContent()));
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
testSystemListener.testComplete(pageToTest, testSummary);
}
}
示例3: runStories
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
private void runStories(String... storyPaths) {
StoryReporterBuilder storyReporterBuilder = new StoryReporterBuilder().withDefaultFormats()
.withCodeLocation(CodeLocations.codeLocationFromClass(ReportTransformBehaviour.class))
.withFormats(Format.XML);
Configuration configuration = new MostUsefulConfiguration()
.useStoryLoader(new LoadFromClasspath(this.getClass())).useStoryReporterBuilder(storyReporterBuilder)
.useFailureStrategy(new SilentlyAbsorbingFailure())
.useStepCollector(new MarkUnmatchedStepsAsPending(new StepFinder(new ByLevenshteinDistance())));
Embedder embedder = new Embedder();
embedder.useEmbedderControls(new EmbedderControls().doGenerateViewAfterStories(false));
embedder.useConfiguration(configuration);
embedder.useCandidateSteps(new InstanceStepsFactory(configuration, new MySteps()).createCandidateSteps());
embedder.useMetaFilters(asList("-skip true"));
try {
embedder.runStoriesAsPaths(asList(storyPaths));
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: shouldCreateNewEmbedderWithDefaultControls
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
@Test
public void shouldCreateNewEmbedderWithDefaultControls() {
// Given
AbstractEmbedderTask task = new AbstractEmbedderTask() {
};
// When
Embedder embedder = task.newEmbedder();
// Then
EmbedderControls embedderControls = embedder.embedderControls();
assertThat(embedderControls.batch(), is(false));
assertThat(embedderControls.generateViewAfterStories(), is(true));
assertThat(embedderControls.ignoreFailureInStories(), is(false));
assertThat(embedderControls.ignoreFailureInView(), is(false));
assertThat(embedderControls.skip(), is(false));
assertThat(embedderControls.verboseFailures(), is(false));
assertThat(embedderControls.verboseFiltering(), is(false));
assertThat(embedderControls.storyTimeoutInSecs(), equalTo(300L));
assertThat(embedderControls.threads(), equalTo(1));
}
示例5: shouldCreateNewEmbedderWithSystemProperties
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
@Test
public void shouldCreateNewEmbedderWithSystemProperties() throws IOException {
// Given
AbstractEmbedderTask task = new AbstractEmbedderTask() {
};
// When
Properties systemProperties = new Properties();
systemProperties.setProperty("one", "1");
systemProperties.setProperty("two", "2");
ByteArrayOutputStream out = new ByteArrayOutputStream();
systemProperties.store(out, "");
task.setSystemProperties(out.toString());
Embedder embedder = task.newEmbedder();
// Then
assertThat(embedder.systemProperties(), equalTo(systemProperties));
}
示例6: shouldGenerateStoriesView
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
@Test
public void shouldGenerateStoriesView() {
// Given
GenerateStoriesView task = new GenerateStoriesView() {
@Override
protected Embedder newEmbedder() {
return embedder;
}
};
// When
task.execute();
// Then
verify(embedder).generateReportsView();
}
示例7: shouldReportStepdocs
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
@Test
public void shouldReportStepdocs() {
// Given
ReportStepdocs task = new ReportStepdocs() {
@Override
protected Embedder newEmbedder() {
return embedder;
}
};
// When
task.execute();
// Then
verify(embedder).reportStepdocs();
}
示例8: shouldCreateNewEmbedderWithDefaultControls
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
@Test
public void shouldCreateNewEmbedderWithDefaultControls() {
// Given
AbstractEmbedderMojo mojo = new AbstractEmbedderMojo() {
public void execute() throws MojoExecutionException, MojoFailureException {
}
};
// When
Embedder embedder = mojo.newEmbedder();
// Then
EmbedderControls embedderControls = embedder.embedderControls();
assertThat(embedderControls.batch(), is(false));
assertThat(embedderControls.generateViewAfterStories(), is(true));
assertThat(embedderControls.ignoreFailureInStories(), is(false));
assertThat(embedderControls.ignoreFailureInView(), is(false));
assertThat(embedderControls.threads(), is(1));
assertThat(embedderControls.skip(), is(false));
assertThat(embedderControls.storyTimeoutInSecs(), equalTo(300L));
assertThat(embedderControls.threads(), equalTo(1));
}
示例9: shouldCreateNewEmbedderWithGivenControls
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
@Test
public void shouldCreateNewEmbedderWithGivenControls() {
// Given
AbstractEmbedderMojo mojo = new AbstractEmbedderMojo() {
public void execute() throws MojoExecutionException, MojoFailureException {
}
};
// When
mojo.batch = true;
mojo.generateViewAfterStories = false;
mojo.ignoreFailureInStories = true;
mojo.ignoreFailureInView = true;
mojo.storyTimeoutInSecs = 60;
mojo.threads = 2;
mojo.skip = true;
Embedder embedder = mojo.newEmbedder();
// Then
EmbedderControls embedderControls = embedder.embedderControls();
assertThat(embedderControls.batch(), is(true));
assertThat(embedderControls.generateViewAfterStories(), is(false));
assertThat(embedderControls.ignoreFailureInStories(), is(true));
assertThat(embedderControls.ignoreFailureInView(), is(true));
assertThat(embedderControls.storyTimeoutInSecs(), is(60L));
assertThat(embedderControls.threads(), is(2));
assertThat(embedderControls.skip(), is(true));
}
示例10: shouldCreateNewEmbedderWithSystemProperties
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
@Test
public void shouldCreateNewEmbedderWithSystemProperties() {
// Given
AbstractEmbedderMojo mojo = new AbstractEmbedderMojo() {
public void execute() throws MojoExecutionException, MojoFailureException {
}
};
// When
Properties systemProperties = new Properties();
systemProperties.setProperty("one", "1");
systemProperties.setProperty("two", "2");
mojo.systemProperties = systemProperties;
Embedder embedder = mojo.newEmbedder();
// Then
assertThat(embedder.systemProperties(), equalTo(systemProperties));
}
示例11: shouldGenerateStoriesView
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
@Test
public void shouldGenerateStoriesView() throws MojoExecutionException, MojoFailureException {
// Given
GenerateStoriesView mojo = new GenerateStoriesView() {
@Override
protected Embedder newEmbedder() {
return embedder;
}
};
// When
mojo.execute();
// Then
verify(embedder).generateReportsView();
}
示例12: shouldReportStepdocs
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
@Test
public void shouldReportStepdocs() throws MojoExecutionException, MojoFailureException {
// Given
ReportStepdocs mojo = new ReportStepdocs() {
@Override
protected Embedder newEmbedder() {
return embedder;
}
};
// When
mojo.execute();
// Then
verify(embedder).reportStepdocs();
}
示例13: shouldReportFailuresWhenReportingStepdocs
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
@Test(expected = MojoFailureException.class)
public void shouldReportFailuresWhenReportingStepdocs() throws MojoExecutionException, MojoFailureException {
// Given
ReportStepdocs mojo = new ReportStepdocs() {
@Override
protected Embedder newEmbedder() {
return embedder;
}
};
// When
doThrow(new RuntimeException()).when(embedder).reportStepdocs();
mojo.execute();
// Then fail as expected
}
示例14: injectEmbedder
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
protected Object injectEmbedder(Embedder embedder, Class<?> annotatedClass) {
try {
Object instance = annotatedClass.newInstance();
if (instance instanceof Embeddable) {
Embeddable embeddable = (Embeddable) instance;
embeddable.useEmbedder(embedder);
}
if (instance instanceof ConfigurableEmbedder) {
ConfigurableEmbedder configurableEmbedder = (ConfigurableEmbedder) instance;
configurableEmbedder.useConfiguration(embedder.configuration());
configurableEmbedder.addSteps(embedder.candidateSteps());
configurableEmbedder.useStepsFactory(embedder.stepsFactory());
}
return instance;
} catch (Exception e) {
annotationMonitor.elementCreationFailed(annotatedClass, e);
throw new InstantiationFailed(annotatedClass, e);
}
}
示例15: shouldRunASingleStory
import org.jbehave.core.embedder.Embedder; //导入依赖的package包/类
@Test
public void shouldRunASingleStory() throws Throwable {
// Given
Embedder embedder = mock(Embedder.class);
Configuration configuration = mock(Configuration.class);
StoryPathResolver pathResolver = mock(StoryPathResolver.class);
when(embedder.configuration()).thenReturn(configuration);
when(configuration.storyPathResolver()).thenReturn(pathResolver);
Class<MyStory> storyClass = MyStory.class;
String storyPath = "/path/to/story";
when(pathResolver.resolve(storyClass)).thenReturn(storyPath);
CandidateSteps steps = mock(CandidateSteps.class);
// When
MyStory story = new MyStory(configuration, steps);
story.useEmbedder(embedder);
story.run();
// Then
verify(embedder).useConfiguration(configuration);
verify(embedder).useCandidateSteps(eq(asList(steps)));
verify(embedder).runStoriesAsPaths(asList(storyPath));
}