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

Running (spring) integration speks? #50

Closed
jasperblues opened this issue Nov 17, 2015 · 26 comments
Closed

Running (spring) integration speks? #50

jasperblues opened this issue Nov 17, 2015 · 26 comments

Comments

@jasperblues
Copy link

Is there an equivalent for the following JUnit?

@RunWith(SpringJUnit4ClassRunner::class)
@ContextConfiguration(classes = arrayOf(Application::class), loader = SpringApplicationContextLoader::class)
@WebIntegrationTest
@mikegehard
Copy link

+1 for this issue.

Maybe there is some lessons that could be learned from:

https://github.com/dam5s/kspec/tree/master/libraries/kspec-spring

@ieugen
Copy link

ieugen commented Jun 8, 2016

Any updates on this?

@raniejade
Copy link
Member

No plans yet, going to push 1.0 first before dealing with this.

@hhariri
Copy link
Contributor

hhariri commented Jul 13, 2016

We can revisit this after the 1.0 release.

@rafal-glowinski
Copy link

+1 here guys.

@wilkinsona
Copy link

Please let us (the Spring Boot team) know if there's anything we can do to help

@dam5s
Copy link

dam5s commented Jul 13, 2016

I have implemented a runner for my own library (Aspen) that uses the SpringContextManager. It's actually pretty simple to get a runner working, the Spring team has done a great job at abstracting the way to run tests using Spring.

You can find the runner I implemented there: https://github.com/dam5s/aspen/blob/master/libraries/aspen-spring/src/main/kotlin/io/damo/aspen/spring/SpringTestTreeRunner.kt

@hhariri
Copy link
Contributor

hhariri commented Jul 14, 2016

@wilkinsona @dam5s Thanks Andy, Damien. We really would like to get 1.0 out the door with as much as the planned functionality and there's still quite a bit to do. As soon as that happens I think we can pick this up and start work on it.

@rafal-glowinski
Copy link

So, we have 1.0 out. Any plans for Spring Integration once you have the Spek API stabilized?

@artem-zinnatullin
Copy link
Collaborator

Not a Spring user: please don't include Spring support to the core
(separate lib will be better), thanks.

On 4 Sep 2016 1:07 pm, "Rafal Glowinski" [email protected] wrote:

So, we have 1.0 out. Any plans for Spring Integration once you have the
Spek API stabilized?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#50 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AA7B3Bw2G6-rFIwFph16YqYr66BDhfiXks5qmqZ6gaJpZM4GjsEO
.

@hhariri
Copy link
Contributor

hhariri commented Sep 5, 2016

@artem-zinnatullin We won't be doing that.
@rafal-glowinski We'll get to this.

@raniejade
Copy link
Member

I'm still working on a spec for extension which can be found here (#115), feedback is very much welcomed.

@dreamkidd
Copy link

Any progress on this?

@raniejade
Copy link
Member

hey guys, v1.1.0-beta3 is out with extension support. Will create a proof of concept sometime next week, so stay tuned.

@raniejade
Copy link
Member

Hey guys, been looking into Spring's TestContext framework which is the backbone of its integration testing support. It makes certain assumptions on how tests, specifically tests are defined as class methods. We can have a workaround for bootstrapping spring's ApplicationContext, but for certain features it will be hard and maybe impossible to support (transactions, @IfProfileValue, @Timed, @Repeat, ...). Anyway, I'll update this ticket once I have more progress.

@raniejade
Copy link
Member

Here's the POC https://github.com/spekframework/spek-spring-extension. It's very hackish, but it will be a good starting point.

I'm closing this issue, feel free to file feature requests on that repo.

@sdeleuze
Copy link

@raniejade Please create an issue on https://jira.spring.io/browse/SPR/ with more details about what changes you would need in TestContext to make it more Spek friendly, I will try to see if something can be done for Spring Framework 5.0 RELEASE.

@raniejade
Copy link
Member

thanks @sdeleuze! I'll find sometime later today 👍

@raniejade
Copy link
Member

@sdeleuze https://jira.spring.io/browse/SPR-15143 :)

@bondpp7
Copy link

bondpp7 commented May 4, 2018

@wilkinsona or @sdeleuze: any word on https://jira.spring.io/browse/SPR-15143? It's been
"waiting for triage" for more than a year. Without the ability to integrate with spring's context, our adoption of Spek is hamstrung.

@wilkinsona
Copy link

@bondpp7 Sorry, I can't help you there. Some input from @sbrannen is needed.

@sbrannen
Copy link

sbrannen commented May 9, 2018

Hi everybody,

I don't foresee any easy way to support testing frameworks based on lambda expressions or closures with the Spring TestContext Framework, simply because the two programming models are completely different with regard to registration (and more importantly lookup) of metadata as well as test execution lifecycle.

I'll post something similar on the related JIRA issue for Spring and will seek feedback there.

Regards,

Sam

@jffiorillo
Copy link

hi guys, I'm looking for the function used in the sample but seems like the sample is based on spek version 1.1.0-beta3 and the current version is 2.0.10, a lot of things has changed there.

@raniejade
Copy link
Member

@jffiorillo I think you can still salvage the POC and re-use it (with some modifications) in Spek 2.x. LifecycleListener is still present in 2.x.

@jffiorillo
Copy link

@raniejade thank you for you answer but I found the following issues when attempting to migrate your example to spek2:

  1. The registerListener(this) in Spec doesn't exist anymore in the Spek.
fun Spec.createContext(spec: KClass<*>): SpringContext {
    return SpringContext(TestContextManager(spec.java), this@createContext).apply {
        registerListener(this)
    }
}

I'm guessing that I need to somehow use the root to solve this issue? but I'm not sure 🤔

  1. The spec is used to get a SpecBody and use the function memoized to inject the values from testContext.applicationContext.getBean(T::class.java) but a Spek is not a SpecBody anymore.
inline fun <reified T: Any> inject(): LifecycleAware<T> {
        return spec.memoized {
            testContext.applicationContext.getBean(T::class.java)
        }
    }

I guess that I need to somehow use the LifecycleAware#memoized but I'm not sure.

Can you give me some hints about how to solve those issues? Thank you

@raniejade
Copy link
Member

Root could work, or just use GroupBody which Root inherits from. Also a hint, GroupBody implements LifecycleAware :)

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