valfirst / jbehave-junit-runner

Integrate JBehave better with JUnit. Reports all Stories, Scenarios and Steps as JUnit Suites and Test Cases.
MIT License
74 stars 53 forks source link

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

Open britter opened 10 years ago

britter commented 10 years ago

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).

visusnet commented 10 years ago

@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 commented 10 years ago

@visusnet makes sense to me!

sheldonh commented 9 years ago

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.

cfontes commented 9 years ago

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