---
description: 簡化加入假資料之方法
---

# MockitObject

```
                <dependency>
			<groupId>io.github.chungtsai</groupId>
			<artifactId>test</artifactId>
			<version>0.0.5</version>
			<scope>test</scope>
		</dependency>
```

```java
MockitObject mockitObject = new MockitObject();
mockitObject.registerName("name", () -> "tome");//定義名稱 欄位資料
mockitObject.exclude("appleVo"); //排除進行操作
```

#### 建立隨機變數

```java
AppleVoDTO random = mockitObject.random(new AppleVoDTO(), i -> {
			i.setName4("name4");// 額外待其他自訂值
});
```

#### 清單類隨機變數

```java
List<AppleVoDTO> list = new ArrayList<>();
mockitObject.randomList(list, () -> new AppleVoDTO(), i -> {//mock清單
		i.setName4("list");
	}, 5);
```
