feign-mock

An easy way to test https://github.com/Netflix/feign. Since using feign most of the logic is store into annotations this helps to check if the annotations are right.

Лицензия

Лицензия

Категории

Категории

Feign Сеть HTTP Clients ORM Данные
Группа

Группа

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

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

feign-mock
Последняя версия

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

0.7
Дата

Дата

Тип

Тип

jar
Описание

Описание

feign-mock
An easy way to test https://github.com/Netflix/feign. Since using feign most of the logic is store into annotations this helps to check if the annotations are right.
Ссылка на сайт

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

https://github.com/velo/feign-mock/
Система контроля версий

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

https://github.com/velo/feign-mock/

Скачать feign-mock

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

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

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
io.github.openfeign : feign-core jar 9.4.0

test (4)

Идентификатор библиотеки Тип Версия
io.github.openfeign : feign-gson jar 9.4.0
junit : junit jar 4.12
org.hamcrest : hamcrest-core jar 1.3
org.hamcrest : hamcrest-library jar 1.3

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

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

The contents of this project was donated to Feign project and it’s now available as part of Feig.

feign-mock

Build Status Coverage Status Maven Central Issues Forks Stars

An easy way to test https://github.com/Netflix/feign. Since feign stores most of the logic in annotations, this helps to check if the annotations are correct.

The original article is available here

If mocking feign clients is easy, testing the logic written in annotations is not!

To check if you are parsing the request/response properly, the only way is firing a real request. Well, that doesn’t seem to be a good path to unit (or even integration) test remote services. Any IO change will affect test stability.

That is why I created feign-mock.

With feign-mock you can use pre-loaded JSON strings or streams as content for your responses. It also allows you to verify mocked invocations and feign-mock will hit your annotations to make sure everything works.

Example
  private GitHub github;
  private MockClient mockClient;

  @Before
  public void setup() throws IOException {
    mockClient = new MockClient()
        .noContent(HttpMethod.PATCH, "/repos/velo/feign-mock/contributors");

    github = Feign.builder()
        .decoder(new GsonDecoder())
        .client(mockClient)
        .target(new MockTarget<>(GitHub.class));
  }

  @After
  public void tearDown() {
    mockClient.verifyStatus();
  }

  @Test
  public void missHttpMethod() {
    List<Contributor> result = github.patchContributors("velo", "feign-mock");
    assertThat(result, nullValue());
    mockClient.verifyOne(HttpMethod.PATCH, "/repos/velo/feign-mock/contributors");
  }

This simple test returns no content and verifies that the URL was truly invoked.

On the mocked client, you can include all URLs and methods you want to mock.

For more comprehensive examples take a look at MockClientTest.

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

Версия
0.7
0.6
0.5
0.4
0.3
0.2
0.1