auto inject for spock framework


Лицензия

Лицензия

Категории

Категории

Spock Тестирование приложения и мониторинг
Группа

Группа

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

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

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

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

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

auto inject for spock framework
auto inject for spock framework
Ссылка на сайт

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

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

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

https://github.com/xiaozhukk/spock-inject

Скачать spock-inject

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

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

Зависимости

compile (1)

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

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

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

spock-inject

auto inject dependencies for spock framework

help Mock and inject beans for Spock unit test framework.

some framework(eg: Spring) help manage beans relations on the runtime, and probability have no setter method for dependent bean. it is hard to Mock the dependent beans.

this extension will make it easy to achieve this purpose by only several Annotations.

@Subject indicate the Object to be tested. this annotation is primitive provided by Spock framework, and we just reuse it. @Mock indicate Objects/beans are required by the Object which to be tested

Repository

<dependency>
  <groupId>com.github.xiaozhukk</groupId>
  <artifactId>spock-inject</artifactId>
  <version>1.0.0</version>
</dependency>

How to use

run SpockAnnotation.init(this) in the setup method

eg:

class Foo {
    @Resource
    private Bar bar;

    public void methodToBeTested() {
        bar.method1();
        // ...
    }
}

class Bar {
    public boolean method1() {
        // ...
    }
}

class FooTest extends Specification{
    @Subject
    Foo foo
    @Mock
    Bar bar

    void setup() {
        SpockAnnotation.init(this)
    }

    def "foo test"() {
        given:
        bar.method1() >> true

        when:
        foo.mehodToBeTested()

        then:
        1 * bar.method1()
    }
}

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

Версия
1.0.0