本文整理汇总了Java中org.jbehave.core.Embeddable类的典型用法代码示例。如果您正苦于以下问题:Java Embeddable类的具体用法?Java Embeddable怎么用?Java Embeddable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Embeddable类属于org.jbehave.core包,在下文中一共展示了Embeddable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveName
import org.jbehave.core.Embeddable; //导入依赖的package包/类
@Override
protected String resolveName(
Class<? extends Embeddable> embeddableClass) {
String simpleName = embeddableClass.getSimpleName();
simpleName = simpleName.replace(wordToRemove, "");
Matcher matcher = compile(resolutionPattern).matcher(
simpleName);
int startAt = 0;
StringBuilder builder = new StringBuilder();
while (matcher.find(startAt)) {
builder.append(matcher.group(1).toLowerCase(locale));
builder.append(SEPARATOR);
startAt = matcher.start(2);
}
return builder.substring(0, builder.length() - 1);
}
示例2: configuration
import org.jbehave.core.Embeddable; //导入依赖的package包/类
@Override
public Configuration configuration() {
Class<? extends Embeddable> embeddableClass = this.getClass();
// Start from default ParameterConverters instance
ParameterConverters parameterConverters = new ParameterConverters();
// factory to allow parameter conversion and loading from external resources (used by StoryParser too)
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(new LocalizedKeywords(), new LoadFromClasspath(embeddableClass), parameterConverters);
// add custom converters
parameterConverters.addConverters(
new DateConverter(new SimpleDateFormat("yyyy-MM-dd")),
new ParameterConverters.EnumConverter()
);
return new MostUsefulConfiguration()
.useStoryLoader(new LoadFromClasspath(embeddableClass))
.useStoryParser(new RegexStoryParser(examplesTableFactory))
.useStoryReporterBuilder(new StoryReporterBuilder()
.withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass))
.withDefaultFormats()
.withFormats(CONSOLE, TXT, HTML, XML))
.useParameterConverters(parameterConverters);
}
示例3: configuration
import org.jbehave.core.Embeddable; //导入依赖的package包/类
/**
* <p>
* Configuration de l'environnement d'exécution de JBehave :
* <ul>
* <li>CONSOLE : sortie des rapports en console pour facilitrer la phase de
* développement dans l'IDE</li>
* <li>HTML_TEMPLATE : génération de rapports HTML pour une meilleure
* lisibilité au niveau de la PIC</li>
* <li>Stratégie transmise à useStepMonitor() :
* <ul>
* <li>Par défaut : stratégie qui veut que les étapes du test à PENDING
* soient ignorées, ainsi le test passe.</li>
* <li>new FailingUponPendingStep() : stratégie qui veut que les étapes du
* test à PENDING fassent échouer le test.</li>
* </ul>
* </li>
* </ul>
* </p>
*/
@Override
public Configuration configuration() {
Class<? extends Embeddable> embeddableClass = this.getClass();
URL codeLocation = codeLocationFromClass(embeddableClass);
StoryReporterBuilder storyReporter = //
new StoryReporterBuilder() //
.withCodeLocation(codeLocation) //
.withDefaultFormats() //
.withFormats(CONSOLE, //
HTML_TEMPLATE) //
.withFailureTrace(true) //
.withFailureTraceCompression(true) //
.withCrossReference(xref);
return new MostUsefulConfiguration() //
.useStoryLoader(new UTF8StoryLoader(embeddableClass)) //
.useStoryReporterBuilder(storyReporter) //
.usePendingStepStrategy(new FailingUponPendingStep()) //
.useStepMonitor(xref.getStepMonitor());
}
示例4: configuration
import org.jbehave.core.Embeddable; //导入依赖的package包/类
@Override
public Configuration configuration() {
Class<? extends Embeddable> embeddableClass = this.getClass();
// Start from default ParameterConverters instance
ParameterConverters parameterConverters = new ParameterConverters();
// factory to allow parameter conversion and loading from external resources (used by StoryParser too)
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(new LocalizedKeywords(), new LoadFromClasspath(embeddableClass), parameterConverters);
// add custom converters
parameterConverters.addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")),
new ExamplesTableConverter(examplesTableFactory));
return new MostUsefulConfiguration()
.useStoryLoader(new LoadFromClasspath(embeddableClass))
.useStoryParser(new RegexStoryParser(examplesTableFactory))
.useStoryReporterBuilder(new StoryReporterBuilder()
.withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass))
.withDefaultFormats()
.withFormats(CONSOLE, TXT, HTML, XML))
.useParameterConverters(parameterConverters);
}
示例5: configuration
import org.jbehave.core.Embeddable; //导入依赖的package包/类
@Override
public Configuration configuration() {
Class<? extends Embeddable> embeddableClass = this.getClass();
Properties viewResources = new Properties();
viewResources.put("decorateNonHtml", "true");
return new MostUsefulConfiguration()
.useParanamer(paranamer)
.useStoryLoader(new LoadFromClasspath(embeddableClass))
.useStoryPathResolver(new UnderscoredCamelCaseResolver().removeFromClassName("Story"))
.useStoryReporterBuilder(new StoryReporterBuilder()
.withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass))
.withDefaultFormats()
.withPathResolver(new FilePrintStreamFactory.ResolveToPackagedName())
.withViewResources(viewResources)
.withFormats(CONSOLE, TXT, HTML, XML))
.useParameterConverters(new ParameterConverters()
.addConverters(new ParameterConverters.NumberConverter(), new DateConverter(new SimpleDateFormat("yyyy-MM-dd")))) // use custom date pattern
.useStepPatternParser(new RegexPrefixCapturingPatternParser(
"$")) // use '%' instead of '$' to identify parameters
.useStepMonitor(new SilentStepMonitor());
}
示例6: resolveName
import org.jbehave.core.Embeddable; //导入依赖的package包/类
@Override
protected String resolveName(final Class<? extends Embeddable> embeddableClass) {
String simpleName = embeddableClass.getSimpleName();
for (final String wordToRemove : this.wordsToRemove) {
simpleName = simpleName.replace(wordToRemove, "");
}
final Matcher matcher = Pattern.compile(this.resolutionPattern).matcher(simpleName);
int startAt = 0;
final StringBuilder builder = new StringBuilder();
while (matcher.find(startAt)) {
builder.append(matcher.group(1).toLowerCase(this.locale));
builder.append(JBossUnderscoredCamelCaseResolver.UNDERSCORE);
startAt = matcher.start(4);
}
return builder.substring(0, builder.length() - 1);
}
示例7: configuration
import org.jbehave.core.Embeddable; //导入依赖的package包/类
@Override
public Configuration configuration() {
Class<? extends Embeddable> embeddableClass = this.getClass();
// Start from default ParameterConverters instance
ParameterConverters parameterConverters = new ParameterConverters();
// factory to allow parameter conversion and loading from external resources (used by StoryParser too)
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(new LocalizedKeywords(), new LoadFromClasspath(embeddableClass), parameterConverters);
// add custom converters
parameterConverters.addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")),
new ExamplesTableConverter(examplesTableFactory));
return new MostUsefulConfiguration()
.useStoryLoader(new LoadFromClasspath(embeddableClass))
.useStoryParser(new RegexStoryParser(examplesTableFactory))
.useStoryReporterBuilder(new StoryReporterBuilder()
.withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass))
.withDefaultFormats()
.withFormats(CONSOLE, TXT, HTML, XML))
.useParameterConverters(parameterConverters);
}
示例8: runStoriesWithAnnotatedEmbedderRunner
import org.jbehave.core.Embeddable; //导入依赖的package包/类
public void runStoriesWithAnnotatedEmbedderRunner(List<String> classNames) {
EmbedderClassLoader classLoader = classLoader();
for (String className : classNames) {
embedderMonitor.runningWithAnnotatedEmbedderRunner(className);
AnnotatedEmbedderRunner runner = AnnotatedEmbedderUtils.annotatedEmbedderRunner(className, classLoader);
try {
Object annotatedInstance = runner.createTest();
if (annotatedInstance instanceof Embeddable) {
((Embeddable) annotatedInstance).run();
} else {
embedderMonitor.annotatedInstanceNotOfType(annotatedInstance, Embeddable.class);
}
} catch (Throwable e) {
throw new AnnotatedEmbedderRunFailed(runner, e);
}
}
}
示例9: reportStepdocsAsEmbeddables
import org.jbehave.core.Embeddable; //导入依赖的package包/类
public void reportStepdocsAsEmbeddables(List<String> classNames) {
EmbedderControls embedderControls = embedderControls();
if (embedderControls.skip()) {
embedderMonitor.embeddablesSkipped(classNames);
return;
}
for (Embeddable embeddable : embeddables(classNames, classLoader())) {
if (embeddable instanceof ConfigurableEmbedder) {
ConfigurableEmbedder configurableEmbedder = (ConfigurableEmbedder) embeddable;
List<CandidateSteps> steps = configurableEmbedder.candidateSteps();
if (steps.isEmpty()) {
steps = configurableEmbedder.stepsFactory().createCandidateSteps();
}
reportStepdocs(configurableEmbedder.configuration(), steps);
} else {
embedderMonitor.embeddableNotConfigurable(embeddable.getClass().getName());
}
}
}
示例10: injectEmbedder
import org.jbehave.core.Embeddable; //导入依赖的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);
}
}
示例11: resolveName
import org.jbehave.core.Embeddable; //导入依赖的package包/类
@Override
protected String resolveName(
Class<? extends Embeddable> embeddableClass) {
String simpleName = embeddableClass.getSimpleName();
simpleName = simpleName.replace(wordToRemove, "");
Matcher matcher = compile(resolutionPattern).matcher(
simpleName);
int startAt = 0;
StringBuilder builder = new StringBuilder();
while (matcher.find(startAt)) {
builder.append(matcher.group(1).toLowerCase(locale));
builder.append(UNDERSCORE);
startAt = matcher.start(2);
}
return builder.substring(0, builder.length() - 1);
}
示例12: shouldMapStoriesAsEmbeddables
import org.jbehave.core.Embeddable; //导入依赖的package包/类
@Test
public void shouldMapStoriesAsEmbeddables() throws Throwable {
// Given
StoryRunner runner = mock(StoryRunner.class);
OutputStream out = new ByteArrayOutputStream();
EmbedderMonitor monitor = new PrintStreamEmbedderMonitor(new PrintStream(out));
String myEmbeddableName = MyStoryMaps.class.getName();
List<String> classNames = asList(myEmbeddableName);
Embeddable myEmbeddable = new MyStoryMaps();
List<Embeddable> embeddables = asList(myEmbeddable);
EmbedderClassLoader classLoader = mock(EmbedderClassLoader.class);
when(classLoader.newInstance(Embeddable.class, myEmbeddableName)).thenReturn(myEmbeddable);
// When
Configuration configuration = new MostUsefulConfiguration();
Embedder embedder = embedderWith(runner, new EmbedderControls(), monitor);
embedder.useClassLoader(classLoader);
embedder.useConfiguration(configuration);
embedder.runAsEmbeddables(classNames);
// Then
for (Embeddable embeddable : embeddables) {
assertThat(out.toString(), containsString("Running embeddable " + embeddable.getClass().getName()));
}
assertThat(MyStoryMaps.run, is(true));
}
示例13: shouldThrowExceptionUponFailingStoriesAsEmbeddablesIfIgnoreFailureInStoriesFlagIsNotSet
import org.jbehave.core.Embeddable; //导入依赖的package包/类
@Test(expected = RunningEmbeddablesFailed.class)
public void shouldThrowExceptionUponFailingStoriesAsEmbeddablesIfIgnoreFailureInStoriesFlagIsNotSet()
throws Throwable {
// Given
StoryRunner runner = mock(StoryRunner.class);
EmbedderControls embedderControls = new EmbedderControls();
OutputStream out = new ByteArrayOutputStream();
EmbedderMonitor monitor = new PrintStreamEmbedderMonitor(new PrintStream(out));
String myEmbeddableName = MyEmbeddable.class.getName();
String myOtherEmbeddableName = MyOtherEmbeddable.class.getName();
List<String> classNames = asList(myEmbeddableName, myOtherEmbeddableName);
Embeddable myEmbeddable = new MyFailingEmbeddable();
Embeddable myOtherEmbeddable = new MyOtherEmbeddable();
EmbedderClassLoader classLoader = mock(EmbedderClassLoader.class);
when(classLoader.newInstance(Embeddable.class, myEmbeddableName)).thenReturn(myEmbeddable);
when(classLoader.newInstance(Embeddable.class, myOtherEmbeddableName)).thenReturn(myOtherEmbeddable);
// When
Embedder embedder = embedderWith(runner, embedderControls, monitor);
embedder.useClassLoader(classLoader);
embedder.runAsEmbeddables(classNames);
// Then fail as expected
}
示例14: shouldThrowExceptionUponFailingStoriesAsEmbeddablesInBatchIfIgnoreFailureInStoriesFlagIsNotSet
import org.jbehave.core.Embeddable; //导入依赖的package包/类
@Test(expected = RunningEmbeddablesFailed.class)
public void shouldThrowExceptionUponFailingStoriesAsEmbeddablesInBatchIfIgnoreFailureInStoriesFlagIsNotSet()
throws Throwable {
// Given
StoryRunner runner = mock(StoryRunner.class);
EmbedderControls embedderControls = new EmbedderControls().doBatch(true);
OutputStream out = new ByteArrayOutputStream();
EmbedderMonitor monitor = new PrintStreamEmbedderMonitor(new PrintStream(out));
String myStoryName = MyStory.class.getName();
String myOtherStoryName = MyOtherEmbeddable.class.getName();
List<String> classNames = asList(myStoryName, myOtherStoryName);
Embeddable myStory = new MyFailingEmbeddable();
Embeddable myOtherStory = new MyOtherEmbeddable();
EmbedderClassLoader classLoader = mock(EmbedderClassLoader.class);
when(classLoader.newInstance(Embeddable.class, myStoryName)).thenReturn(myStory);
when(classLoader.newInstance(Embeddable.class, myOtherStoryName)).thenReturn(myOtherStory);
// When
Embedder embedder = embedderWith(runner, embedderControls, monitor);
embedder.useClassLoader(classLoader);
embedder.runAsEmbeddables(classNames);
// Then fail as expected
}
示例15: configuration
import org.jbehave.core.Embeddable; //导入依赖的package包/类
@Override
public Configuration configuration() {
Class<? extends Embeddable> embeddableClass = this.getClass();
// Start from default ParameterConverters instance
ParameterConverters parameterConverters = new ParameterConverters();
// factory to allow parameter conversion and loading from external resources (used by StoryParser too)
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(new LocalizedKeywords(), new LoadFromClasspath(embeddableClass), parameterConverters);
// add custom coverters
parameterConverters.addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")),
new ExamplesTableConverter(examplesTableFactory));
// parameterConverters.addConverters(new MyConverter());
// parameterConverters.addConverters(new StudentConverter(new ExamplesTableFactory()));
CrossReference xref = new CrossReference();
return new MostUsefulConfiguration()
.useStoryLoader(new LoadFromClasspath(embeddableClass))
.useStoryParser(new RegexStoryParser(examplesTableFactory))
.useStoryReporterBuilder(new StoryReporterBuilder()
.withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass))
.withDefaultFormats()
.withCrossReference(xref )
.withFormats(CONSOLE, TXT, WebDriverHtmlOutput.WEB_DRIVER_HTML, XML))
.useParameterConverters(parameterConverters);
}