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

Add Spek integration #107

Closed
wants to merge 1 commit into from
Closed

Add Spek integration #107

wants to merge 1 commit into from

Conversation

OsQu
Copy link

@OsQu OsQu commented Apr 4, 2018

Most of the extending functionality is from this issue explaining how to extend Spek: spekframework/spek#115

The integration happens by injecting KoinComponent to Spec class. This enables Koin DSL to be used within Spek tests. KoinSpek.kt adds AutoCloseKoinSpek class similar to AutoCloseKoinTest class.

Usage

Add koin-spek as dependency, e.g.

    testCompile "org.koin:koin-spek:$koin_version"

Switch Spek class to KoinSpek (or AutoCloseKoinSpek) and write the tests normally. Here is minimal example:

class HelloService

val module = applicationContext {
    bean { HelloService() }
}

class KoinDSLTest : AutoCloseKoinSpek({
    describe("DSL") {
        it("is possible to use inject") {
            StandAloneContext.startKoin(listOf(module))

            val helloService: HelloService by inject()
            Assert.assertNotNull(helloService)
        }
    }
})

KoinDSLTest.kt contains the full example.

Spek requires quite a bit of runtime dependencies that are not needed on compile time. I'm not sure whether it is feasible to include in build.gradle file or not. If not, I'm happy to take the tests away.

Injects KoinComponent to Spec class. This enables Koin DSL to be used
within Spek tests
@OsQu
Copy link
Author

OsQu commented Apr 4, 2018

If you think this is feasible, I'll include a Koin Spek README section as well

@arnaudgiuliani arnaudgiuliani added this to the 1.0.0 milestone Apr 10, 2018
@arnaudgiuliani
Copy link
Member

Hello, we will begin to check that for 1.0.0. Stay in touch

@arnaudgiuliani arnaudgiuliani added type:feature-proposal status:checking currently in analysis - discussion or need more detailed specs labels May 11, 2018
@arnaudgiuliani arnaudgiuliani modified the milestone: 1.0.0 May 11, 2018
@arnaudgiuliani
Copy link
Member

I'm currently preparing the 1.0.0 base branch. Stay tuned 👍

@OsQu
Copy link
Author

OsQu commented May 11, 2018 via email

@arnaudgiuliani arnaudgiuliani removed this from the 1.0.0 milestone Jul 6, 2018
@arnaudgiuliani arnaudgiuliani added status:waiting and removed status:checking currently in analysis - discussion or need more detailed specs labels Aug 16, 2018
@arnaudgiuliani
Copy link
Member

@OsQu would you make koin 2.0 proposal?

@arnaudgiuliani
Copy link
Member

I close it, but we can continue discuss about it.

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

Successfully merging this pull request may close these issues.

2 participants