fixture-monkey-mockito

Features

Generating mock interafce, abstract class by Mockito

How-to

1. Adding dependency

testImplementation("com.navercorp.fixturemonkey:fixture-monkey-mockito:1.1.0")
<dependency>
  <groupId>com.navercorp.fixturemonkey</groupId>
  <artifactId>fixture-monkey-mockito</artifactId>
  <version>1.1.0</version>
  <scope>test</scope>
</dependency>

2. Adding option plugin

FixtureMonkey fixtureMonkey = FixtureMonkey.builder()
    .plugin(new MockitoPlugin())
    .build();

Usage

@Data   // lombok getter, setter
public class Order {
    @NotNull
    private Long id;
    
    private String productName;

    private int quantity;
    
    @NotNull
    private Item item;
}

public interface Item {
    String getName();
}

@Test
void test() {
    // given
    FixtureMonkey sut = FixtureMonkey.builder()
        .plugin(new MockitoPlugin())
        .build();

    // when
    Order actual = sut.giveMeOne(Order.class);

    // then
    then(actual.getItem()).isNotNull();
    
    when(actual.getItem().getName()).thenReturn("ring");
    then(actual.getItem().getName()).isEqualTo("ring");
}