-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
8ac3daf
commit 7259a15
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
test-spock/src/test/groovy/io/micronaut/test/spock/SharedInjectionSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package io.micronaut.test.spock | ||
|
||
import io.micronaut.context.ApplicationContext | ||
import io.micronaut.test.annotation.MicronautTest | ||
import spock.lang.Shared | ||
import spock.lang.Specification | ||
|
||
import javax.inject.Inject | ||
|
||
class AbstractExample extends Specification { | ||
|
||
@Inject | ||
@Shared | ||
ApplicationContext sharedCtx | ||
|
||
@Inject | ||
ApplicationContext ctx | ||
|
||
} | ||
|
||
@MicronautTest | ||
class FailingTest extends AbstractExample { | ||
|
||
def 'injection is not null'() { | ||
expect: | ||
ctx != null | ||
} | ||
|
||
def 'shared injection is not null'() { | ||
expect: | ||
sharedCtx != null | ||
} | ||
} | ||
|
||
@MicronautTest | ||
class SuccessfulTest extends AbstractExample { | ||
|
||
@Shared | ||
@Inject | ||
ApplicationContext dummy | ||
|
||
def 'injection is not null'() { | ||
expect: | ||
ctx != null | ||
} | ||
|
||
def 'shared injection is not null'() { | ||
expect: | ||
sharedCtx != null | ||
} | ||
} |