Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an example on how to inject members into a test using spring #62

Open
britter opened this issue Jun 28, 2014 · 4 comments
Open

Comments

@britter
Copy link
Contributor

britter commented Jun 28, 2014

We had quite a few requests on how to use the jbehave-junit-runner together with spring. The problem is, that both, our library and spring test provide a JUnitRunner and only one runner can be declared per test.

We should document a way to inject members into a jbehave junit test using spring. The easiest way would probably be, to create an ApplicationContext in the @Before hock by hand, get an AutowireCapableFactoryBean from there and then call autowireBean(Object)passing in the this reference (see also: http://stackoverflow.com/questions/3813588/how-to-inject-dependencies-into-a-self-instantiated-object-in-spring).

@britter britter added this to the 1.2.0 milestone Jun 28, 2014
@visusnet visusnet self-assigned this Jun 28, 2014
@visusnet
Copy link
Contributor

@britter Does it make sense to move the examples to another project (#54) within the same repository (similar to https://github.com/codecentric/zucchini) before #62?

@britter
Copy link
Contributor Author

britter commented Jun 29, 2014

@visusnet makes sense to me!

@sheldonh
Copy link

What's the state of the art now? I have an exploratory project that uses SpringJUnit4ClassRunner to run its stories (see example, but my IDE doesn't show the steps beautifully in its test result navigator. So I want to use jbehave-junit-runner, which has worked beautifully for me with statically configured tests. But I can't use it without Spring autowiring.

@britter britter removed this from the 1.2.0 milestone May 28, 2015
@cfontes
Copy link

cfontes commented Sep 30, 2015

Any news about this? or document about the best practices to put this in place?

I am currently trying it and it's not very strait forward.

The @rule from Spring sounds promising but I couldn't make it work yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants