thucydides-webtests/thucydides

Unable to use spring-context with thucydides-jbehave

Closed this issue · 3 comments

I'm using the thucydides-jbehave-plugin and I'm unable to inject my spring context to load my beans to use in the steps classes.

My only jbehave test suite I'm using to run the tests is:

package com.sratest.jbehave;

import org.jbehave.core.annotations.Configure;
import org.jbehave.core.annotations.spring.UsingSpring;

import net.thucydides.jbehave.ThucydidesJUnitStories;

@Configure
@UsingSpring(resources = {"META-INF/spring/integration/spring-context.xml"})
public class SpringTestSuite extends ThucydidesJUnitStories {

}

I've noticed that this fails to actually load the context (when I comment out the @configure and @UsingSpring in the class above it runs just the same.)

I looked at the manual for thucydides but it only shows spring integrated directly with thucydides and not when used with the jbehave plugin.

I tried part of the example shown but it didn't work

package com.sratest.jbehave;

import org.springframework.test.context.ContextConfiguration;

@ContextConfiguration(locations = "/META-INF/spring/integration/spring-context.xml") 
public class SpringTestSuite extends ThucydidesJUnitStories {
}

Am I missing something obvious? Is there a way to use spring-context/autowire beans within Thucydides-Jbehave?

Used the solution provided on a github gist which allows me to add spring autowire within the JBehave steps in the test classes.

Thucydides understands the normal Spring annotations
(e.g. @ContextConfiguration(locations = "/spring/config.xml")), so you
don't need the JBehave @UsingSpring one.

On 18 July 2014 03:57, Lexijok notifications@github.com wrote:

Used the solution provided on a github gist
https://gist.github.com/jgeraerts/4508903 which allows me to add spring
autowire within the JBehave steps in the test classes.


Reply to this email directly or view it on GitHub
#140 (comment)
.


John Smart | Wakaleo Consulting | +61 407 247 642
Optimizing your software development process
http://www.wakaleo.com | john.smart@wakaleo.com


The dates for the 2014 BDD workshops have been scheduled! Check out our
upcoming BDD/TDD Master classes
http://wakaleo.com/training/testing-and-tdd-for-java-developers and
our Advanced
BDD Requirements Workshops
http://wakaleo.com/training/advanced-agile-requirements-workshop
, coming
soon to Sydney
http://wakaleo.com/training/testing-and-tdd-for-java-developers/public-courses
*
and *Melbourne
http://wakaleo.com/training/testing-and-tdd-for-java-developers/public-courses!


Hi John Smart,
I encountered the same, he can found the spring context in the steps level not on the suite level.

eg:

// this one works
@ContextConfiguration(locations = "/config/*/spring/-config.xml")
public class SampleSteps {
// some codes here

}

// this one does not
@ContextConfiguration(locations = "config/*/spring/-config.xml")
public class AllStoriesTestSuite extends ThucydidesJUnitStories {
// some codes here
}

the better way is to put the context configuration in the suite level to remove the redundancy, however it does not work.