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 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add Spek integration #4

wants to merge 1 commit into from

Conversation

villelaitila
Copy link

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
@softagram softagram deleted a comment from softagram-bot Feb 6, 2019
@softagram-bot
Copy link

This impact report was requested by @TommiTallgren - get yours at https://softagram.com/pull-request-bot

Softagram Impact Report for pull/4 (head commit: fdfa8ce)

⭐ Visual Overview

Changed elements and changed dependencies.
Changed dependencies - click for full size
Graph legend
(Open in Softagram Desktop for full details)

⭐ Change Impact

How the changed files are used by the rest of the project
Impacted files - click for full size
Graph legend
(Open in Softagram Desktop for full details)

📄 Full report

Give feedback of this report to [email protected]

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