Search in sources :

Example 6 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.

the class LocalizedKeywordsBehaviour method shouldAllowKeywordsToBeConfigured.

@Test
public void shouldAllowKeywordsToBeConfigured() {
    Configuration configuration = new MostUsefulConfiguration();
    ensureKeywordsAreLocalised(configuration, new Locale("en"));
    configuration.useKeywords(new LocalizedKeywords(new Locale("it")));
    ensureKeywordsAreLocalised(configuration, new Locale("it"));
}
Also used : Locale(java.util.Locale) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Test(org.junit.Test)

Example 7 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.

the class ScanningStepsFactoryBehaviour method shouldScanStepsFromPackagesAndFilterMatchingNames.

@Test
public void shouldScanStepsFromPackagesAndFilterMatchingNames() {
    InjectableStepsFactory factory = new ScanningStepsFactory(new MostUsefulConfiguration(), "org.jbehave.core.steps.scan").matchingNames(".*GivenWhen.*").notMatchingNames(".*GivenWhenThen");
    List<CandidateSteps> candidateSteps = factory.createCandidateSteps();
    assertThat(candidateSteps.size(), Matchers.equalTo(1));
}
Also used : MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Test(org.junit.Test)

Example 8 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.

the class ScanningStepsFactoryBehaviour method shouldScanStepsFromPackagesAndIgnoreClassesNotAnnotated.

@Test
public void shouldScanStepsFromPackagesAndIgnoreClassesNotAnnotated() {
    InjectableStepsFactory factory = new ScanningStepsFactory(new MostUsefulConfiguration(), "org.jbehave.core.steps.scan", "org.jbehave.core.steps.scan2");
    List<CandidateSteps> candidateSteps = factory.createCandidateSteps();
    assertThat(candidateSteps.size(), Matchers.equalTo(3));
}
Also used : MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Test(org.junit.Test)

Example 9 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.

the class ScanningStepsFactoryBehaviour method shouldScanStepsFromRootClass.

@Test
public void shouldScanStepsFromRootClass() {
    InjectableStepsFactory factory = new ScanningStepsFactory(new MostUsefulConfiguration(), this.getClass());
    List<CandidateSteps> candidateSteps = factory.createCandidateSteps();
    assertThat(candidateSteps.size(), Matchers.greaterThan(1));
}
Also used : MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Test(org.junit.Test)

Example 10 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.

the class StepCreatorBehaviour method shouldStoreAndReadObjects.

private void shouldStoreAndReadObjects(Method methodStoring, boolean resetContext) throws IntrospectionException {
    // Given
    if (resetContext) {
        setupContext();
    }
    SomeSteps stepsInstance = new SomeSteps();
    InjectableStepsFactory stepsFactory = new InstanceStepsFactory(new MostUsefulConfiguration(), stepsInstance);
    StepMatcher stepMatcher = new RegexStepMatcher(StepType.WHEN, "I read from context", Pattern.compile("I read from context"), new String[] {});
    StepCreator stepCreator = new StepCreator(stepsInstance.getClass(), stepsFactory, stepsContext, null, new ParameterControls(), stepMatcher, new SilentStepMonitor());
    // When
    Method methodRead = SomeSteps.methodFor("aMethodReadingFromContext");
    StepResult stepResult = stepCreator.createParametrisedStep(methodStoring, "When I store in context", "I store in context", new HashMap<String, String>()).perform(null);
    StepResult stepResultRead = stepCreator.createParametrisedStep(methodRead, "And I read from context", "I read from context", new HashMap<String, String>()).perform(null);
    // Then
    assertThat(stepResult, instanceOf(Successful.class));
    assertThat(stepResultRead, instanceOf(Successful.class));
    assertThat(stepsInstance.args, instanceOf(String.class));
    assertThat((String) stepsInstance.args, is("someValue"));
}
Also used : RegexStepMatcher(org.jbehave.core.parsers.RegexStepMatcher) StepMatcher(org.jbehave.core.parsers.StepMatcher) HashMap(java.util.HashMap) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Method(java.lang.reflect.Method) Matchers.anyString(org.mockito.Matchers.anyString) Successful(org.jbehave.core.steps.AbstractStepResult.Successful) RegexStepMatcher(org.jbehave.core.parsers.RegexStepMatcher)

Aggregations

MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)66 Test (org.junit.Test)52 Configuration (org.jbehave.core.configuration.Configuration)14 CandidateSteps (org.jbehave.core.steps.CandidateSteps)14 StoryReporterBuilder (org.jbehave.core.reporters.StoryReporterBuilder)11 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)8 TableTransformers (org.jbehave.core.model.TableTransformers)8 Method (java.lang.reflect.Method)7 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)7 ParameterConverters (org.jbehave.core.steps.ParameterConverters)7 SimpleDateFormat (java.text.SimpleDateFormat)5 HashMap (java.util.HashMap)5 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)5 UsingEmbedder (org.jbehave.core.annotations.UsingEmbedder)5 BeforeOrAfterFailed (org.jbehave.core.failures.BeforeOrAfterFailed)5 Failed (org.jbehave.core.steps.AbstractStepResult.Failed)5 ApplicationContext (org.springframework.context.ApplicationContext)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 OutputStream (java.io.OutputStream)4 PrintStream (java.io.PrintStream)4