Spock-HK2

Spock extension which helps writing integration tests in your HK2-based application with explicit binders.

Лицензия

Лицензия

Категории

Категории

Spock Тестирование приложения и мониторинг HK2 Библиотеки уровня приложения Dependency Injection
Группа

Группа

com.github.pbetkier
Идентификатор

Идентификатор

spock-hk2
Последняя версия

Последняя версия

0.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Spock-HK2
Spock extension which helps writing integration tests in your HK2-based application with explicit binders.
Ссылка на сайт

Ссылка на сайт

https://github.com/pbetkier/spock-hk2
Система контроля версий

Система контроля версий

https://github.com/pbetkier/spock-hk2

Скачать spock-hk2

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.pbetkier/spock-hk2/ -->
<dependency>
    <groupId>com.github.pbetkier</groupId>
    <artifactId>spock-hk2</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.pbetkier/spock-hk2/
implementation 'com.github.pbetkier:spock-hk2:0.1.0'
// https://jarcasting.com/artifacts/com.github.pbetkier/spock-hk2/
implementation ("com.github.pbetkier:spock-hk2:0.1.0")
'com.github.pbetkier:spock-hk2:jar:0.1.0'
<dependency org="com.github.pbetkier" name="spock-hk2" rev="0.1.0">
  <artifact name="spock-hk2" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.pbetkier', module='spock-hk2', version='0.1.0')
)
libraryDependencies += "com.github.pbetkier" % "spock-hk2" % "0.1.0"
[com.github.pbetkier/spock-hk2 "0.1.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.spockframework : spock-core jar 0.7-groovy-2.0

Модули Проекта

Данный проект не имеет модулей.

Spock-HK2 Build Status

Spock extension which helps writing integration tests in your HK2-based application with explicit binders.

Installation

Add a dependency on Spock-HK2 from Maven Central, e.g. in Gradle build file:

testCompile 'com.github.pbetkier:spock-hk2:0.1.0'

Spock-HK2 expects org.glassfish.hk2:hk2-locator dependency to be present on the classpath. It is tested with HK2 version of 2.3.0.

Usage

Spock-HK2 provides @UseBinders annotation to define HK2 binders to be used in a given specification and its subclasses. This allows you to inject components into Spock specifications.

@UseBinders(YourBinder)
class ExampleSpec extends Specification {

    @Inject
    YourComponent injectedComponent

    def "should inject components into spec fields"() {
        expect:
        injectedComponent != null
    }

}

You can provide either a single binder or a list of binder classes.

Binder instances

The example above defined binder classes to be used in an integration test. You can also define a binder instance or instances instead or besides binder classes: @UseBinders(instances = { new MyBinder() }) or @UseBinders(instances = { [new MyBinder(), new MyOtherBinder()] }).

Other features

You may define your binders in a superclass, e.g. in a common IntegrationSpec abstract specification. You can inject into @Shared fields as well. Consult the project's tests for more examples.

License

Copyright (C) 2015 Piotr Betkier

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0      

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Версии библиотеки

Версия
0.1.0