Hi,

First, I created a testing project (using JBehave Web) written in
Java. Then I wanted to switch completely to Groovy.

My story class inherits from JUnitStories:

public class InvoiceMeStories extends JUnitStories {
...
}

My first approach was quick and dirty: rename all .java to .groovy
(with some minor changes, like replacing GStrings with Java strings).
I was using still InstanceStepsFactory, because I thought that if I
provide an instance of my steps (CustomerSteps in this case), it would
work:

    @Override
    public List<CandidateSteps> candidateSteps() {
        return new InstanceStepsFactory(configuration(),
            new CustomerSteps(new CustomerPageFactory(driverProvider)),
            new PerStoriesWebDriverSteps(driverProvider), // or
PerStoryWebDriverSteps or PerScenarioWebDriverSteps
            new
WebDriverScreenshotOnFailure(driverProvider)).createCandidateSteps();
    }

After running the tests, I got:

 invoice-me-test ---
[INFO] Running stories using embedder Embedder[...]
[INFO] Found class names: []

No stories was found.

Then, I had a look at the manual and I found an example with GroovyStepsFactory

    @Override
    public List<CandidateSteps> candidateSteps() {
        GroovyResourceFinder resourceFinder = new
GroovyResourceFinder(codeLocationFromPath("src/main/groovy"),
"**/*.story", "");
        return new GroovyStepsFactory(configuration(), new
GroovyContext(resourceFinder)).createCandidateSteps();
    }

But, I my case (I'm using Selenium with WebDriver), how do I add
PerStoriesWebDriverSteps? GroovyStepsFactory constructor does not
admit any additional steps.

Or, should I add these two methods (copied from
PerStoriesWebDriverSteps) to InvoiceMeStories? These methods will add
the functionality of PerStoriesWebDriverSteps without explicitely
instantiating these class:

    @BeforeStories
    public void beforeStories() throws Exception {
        driverProvider.initialize();
    }

    @AfterStories
    public void afterStories() throws Exception {
        driverProvider.get().quit();
    }

Best regards/mit freundlichen Grüssen/Saludos cordiales/Pozdrowienia

Marcin Gryszko
Freelance architect/developer; Sun/Oracle certified (OCM Java EE
Enterprise Architect, SCEA,SCBCD,SCWCD,SCJP)
Contact me for availability and rates:
Mobile: +34658358605, Skype/Twitter: mgryszko



On Fri, Dec 10, 2010 at 9:27 PM, Mauro Talevi
<[email protected]> wrote:
> Hi Marcin,
>
> web steps are qualitatively no different from core steps, the only
> different being that they wrap Selenium (or other web tool).
>
> If you want to use groovy to write your steps, you should use the
> GroovyStepsFactory.
>
> What is the problem you're finding?
>
> Cheers
>
> On 10/12/2010 09:44, Marcin Gryszko wrote:
>> Is it possible to define JBehave Web steps in Groovy? There is an
>> example in the user doc for the plain JBehave. But in case of JBehave
>> Web, should I use GroovyStepsFactory or InstanceStepsFactory?
>>
>> When I try to use InstanceStepsFactory with steps defined in a Groovy
>> class, no stories are found. In my naive approach I simply changed all
>> .java source files to .groovy and compiled them with groovyc.
>>
>> If I try to use GroovyStepsFactory, how do I add
>> PerStoriesWebDriverSteps and WebDriverScreenshotOnFailure?
>>
>> Below you find my preliminary code for JUnitStories.candidateSteps()
>> for Groovy and Java:
>>
>> public class InvoiceMeStories extends JUnitStories {
>>
>>    // GROOVY VERSION
>>
>>   �...@override
>>    public List<CandidateSteps> candidateSteps() {
>>        GroovyResourceFinder resourceFinder = new
>> GroovyResourceFinder(codeLocationFromPath("src/main/groovy"),
>> "**/*.story", "");
>>        return new GroovyStepsFactory(configuration(), new
>> GroovyContext(resourceFinder)).createCandidateSteps();
>>    }
>>
>>
>>    // JAVA VERSION
>>
>>   �...@override
>>    public List<CandidateSteps> candidateSteps() {
>>        return new InstanceStepsFactory(configuration(),
>>            new CustomerSteps(new CustomerPageFactory(driverProvider)),
>>            new PerStoriesWebDriverSteps(driverProvider), // or
>> PerStoryWebDriverSteps or PerScenarioWebDriverSteps
>>            new 
>> WebDriverScreenshotOnFailure(driverProvider)).createCandidateSteps();
>>    }
>> }
>>
>> Best regards/mit freundlichen Grüssen/Saludos cordiales/Pozdrowienia
>>
>> Marcin Gryszko
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to