mirrormocks

Set of mock classes for javax.lang.model interfaces. For use in unit testing annotation processors.

Лицензия

Лицензия

Категории

Категории

Mirror Библиотеки уровня приложения Introspection ORM Данные
Группа

Группа

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

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

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

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

0.2.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

mirrormocks
Set of mock classes for javax.lang.model interfaces. For use in unit testing annotation processors.
Ссылка на сайт

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

https://github.com/diosmosis/java-mirror-mocks
Система контроля версий

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

https://github.com/diosmosis/java-mirror-mocks

Скачать mirrormocks

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

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

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.reflections : reflections jar 0.9.10

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

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

java-mirror-mocks

Description

A set of mock classes for the interfaces in the javax.lang.model package. For use in unit testing code in annotation processors.

Usage

The implementations provided by this package use reflection to mimic the mirror API as closely as possible. So to use it during tests, first create a test class that you'd want a Element for, eg:

@MyAnnotationToProcess
public class TestClassWithAnnotation {
    // ...
}

then create the Element using ElementFactory:

import flarestar.mirror.mock.element.ElementFactory;

public class MyAnnotationProcessorComponentTest {

    private MyAnnotationProcessorComponent instance = new MyAnnotationProcessorComponent();

    @Test
    public void testSomething() {
        TypeElement mockElement = ElementFactory.make(TestClassWithAnnotation.class);

        instance.doSomething(mockElement);
    }

This should result in viable unit tests w/o the verbosity that comes hand in hand w/ using mocking frameworks like mockito.

Caveat

The mirror API is very strange. There are many corner cases that are either impossible to replicate via reflection or are cases where I am not positive what the actual behavior should be. So in some cases these mocks may not behave as expected.

It is thus recommended to couple unit tests w/ integration tests that invoke annotation processors through the compiler API. This way, you can get a larger amount of code coverage and the confidence for success in the real world from integration tests, plus easier debugging when performing refactoring from your unit tests.

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

Версия
0.2.0
0.1.0