Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/naver/fixture-monkey
Let Fixture Monkey generate test instances including edge cases automatically
https://github.com/naver/fixture-monkey
java kotlin random-populated-object test
Last synced: 5 days ago
JSON representation
Let Fixture Monkey generate test instances including edge cases automatically
- Host: GitHub
- URL: https://github.com/naver/fixture-monkey
- Owner: naver
- License: apache-2.0
- Created: 2021-08-19T08:54:37.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-14T06:33:37.000Z (11 days ago)
- Last Synced: 2024-12-14T07:25:10.188Z (11 days ago)
- Topics: java, kotlin, random-populated-object, test
- Language: Java
- Homepage: https://naver.github.io/fixture-monkey
- Size: 28.3 MB
- Stars: 584
- Watchers: 11
- Forks: 94
- Open Issues: 38
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Fixture Monkey
![Maven version](https://maven-badges.herokuapp.com/maven-central/com.navercorp.fixturemonkey/fixture-monkey/badge.svg)
[![Build](https://github.com/naver/fixture-monkey/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/naver/fixture-monkey/actions/workflows/build.yml)
[![GitHub license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/naver/fixture-monkey/blob/main/LICENSE)
Designed by SeongIn Hong### "Write once, Test anywhere"
Fixture Monkey is designed to easily generate controllable arbitrary instances. It allows you to reuse the same configurations of the instances in several tests.
You can write countless tests including edge cases, using just only one instance of the FixtureMonkey type. You can automatically generate instances of complex types and set fields with values from builders of the ArbitraryBuilder type. The well-defined builders can be reused in any test.
Each primitive type property is generated by [Jqwik](https://github.com/jlink/jqwik) or [kotest-property](https://github.com/kotest/kotest).## Requirements
* JDK 1.8 or higher
* Jqwik 1.7.3
* Kotlin 1.8 or higher
* kotest-property 5.9.1## Install
### Gradle
#### Java
```groovy
testImplementation("com.navercorp.fixturemonkey:fixture-monkey-starter:1.1.6")
```#### Kotlin
```groovy
testImplementation("com.navercorp.fixturemonkey:fixture-monkey-starter-kotlin:1.1.6")
```### Maven
#### Java
```xml
com.navercorp.fixturemonkey
fixture-monkey-starter
1.1.6
test```
#### Kotlin
```xml
com.navercorp.fixturemonkey
fixture-monkey-starter-kotlin
1.1.6
test```
## Example
> Add "lombok.anyConstructor.addConstructorProperties=true" in lombok.config#### Java
```java
@Value
public class Order {
Long id;String orderNo;
String productName;
int quantity;
long price;
List items;
Instant orderedAt;
}@Test
void sampleOrder() {
// given
FixtureMonkey sut = FixtureMonkey.builder()
.objectIntrospector(ConstructorPropertiesArbitraryIntrospector.INSTANCE)
.build();// when
Order actual = sut.giveMeBuilder(Order.class)
.set(javaGetter(Order::getOrderNo), "1")
.set(javaGetter(Order::getProductName), "Line Sally")
.minSize(javaGetter(Order::getItems), 1)
.sample();// then
then(actual.getOrderNo()).isEqualTo("1");
then(actual.getProductName()).isEqualTo("Line Sally");
then(actual.getItems()).hasSizeGreaterThanOrEqualTo(1);
}
```#### Kotlin
```kotlin
data class Order (
val id: Long,val orderNo: String,
val productName: String,
val quantity: Int,
val price: Long,
val items: List,
val orderedAt: Instant
)@Test
fun sampleOrder() {
// given
val sut = FixtureMonkey.builder()
.plugin(KotlinPlugin())
.build()// when
val actual = sut.giveMeBuilder()
.setExp(Order::orderNo, "1")
.setExp(Order::productName, "Line Sally")
.minSizeExp(Order::items, 1)
.sample()// then
then(actual.orderNo).isEqualTo("1")
then(actual.productName).isEqualTo("Line Sally")
then(actual.items).hasSizeGreaterThanOrEqualTo(1)
}
```## Documentation
* [English](https://naver.github.io/fixture-monkey)
* [Korean](https://naver.github.io/fixture-monkey/v1-1-0-kor/)## [FAQ](https://naver.github.io/fixture-monkey/v1-0-0/docs/cheat-sheet/faq/)
## [Third-party Modules](https://naver.github.io/fixture-monkey/docs/plugins/)
## Plugins
* [FixtureMonkey Helper](https://plugins.jetbrains.com/plugin/19589-fixturemonkey-helper)
- IntelliJ plugin that makes it easier to use Fixture Monkey string expressions & Kotlin DSL## Contributors
* ๐ [ah.jo](https://github.com/seongside)
* ๐ [mhyeon-lee](https://github.com/mhyeon-lee)
* ๐ [acktsap](https://github.com/acktsap)
* ๐ [benelog](https://github.com/benelog)
* ๐ [jwChung](https://github.com/jwChung)
* ๐ [SooKim1110](https://github.com/SooKim1110)Thanks to all [contributors](https://github.com/naver/fixture-monkey/graphs/contributors)
## More about Fixture Monkey
* [Deview 2021](https://tv.naver.com/v/23650158)## Articles
* [fixure monkey๋ก ์์ธ ๋ฐ์ ํ ์คํธ](https://yangbongsoo.tistory.com/68?category=982054)
* [ํ ์คํธ ๊ฐ์ฒด๋ฅผ ๋์ฝ๊ฒ ๋ง๋ค์ด๋ณด์, Fixture-monkey](https://taes-k.github.io/2021/12/12/fixture-monkey/)
* [Junit Test with Fixture Monkey](https://kevin-park.medium.com/junit-test-with-fixture-monkey-ca50f6533385)
* [Fixture monkey](https://leeheefull.tistory.com/m/27)
* [ํ ์คํธ ๋ฐ์ดํฐ๋๊ตฌ - Fixture Monkey](https://jiwondev.tistory.com/272)
* [Fixture Monkey๋?](https://velog.io/@pang_e/Fixture-Monkey%EB%9E%80)
* [ํ ์คํธ๋ฅผ ์์ฑํ ์ ๋ฐ์ ์๋ ์ฌ๋๋ค์๊ฒ](https://brunch.co.kr/@seongside/3)
* [Fixture Monkey ์ฌ์ฉํด๋ณด๊ธฐ](https://codinghejow.tistory.com/419)
* [Simplify Unit Testing with Fixture Monkey](https://medium.com/naver-platform-labs/simplify-unit-testing-with-fixture-monkey-a-concise-pragmatic-and-interoperable-fixture-library-3bf0206258d4)
* [Getting Started Easy Test Fixture Customization with Fixture Monkey](https://medium.com/naver-platform-labs/easy-test-fixture-customization-with-fixture-monkey-4114c6b4b1ef)
* [[Fixture Monkey] ํฝ์ค์ณ ๋ชฝํค๋ก ํ ์คํธ ์ฝ๋ ์์ฑํ๊ธฐ (Java Spring)](https://sunshower99.tistory.com/33)
* [TestFixture๋ฅผ ์ฝ๊ฒ ์์ฑํด ์ฃผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์๋ค?](https://oliveyoung.tech/blog/2024-04-01/testcode-use-fixture-monkey/)
* [Fixture Monkey๋ก ํ ์คํธ ํฝ์ค์ฒ๋ฅผ ์ฝ๊ฒ ์์ฑํ๊ณ ๋ฆฌํฉํ ๋ง ํด๋ณด์](https://jxmen.github.io/wiki/project/cs-ai-interviewer/refactoring-with-fixture-monkey/)
* [Fixture Monkey๋ฅผ ์ ์ฉํด๋ณด์ w/JPA Test](https://currenjin.github.io/wiki/fixture-monkey-with-jpa/#fixture-monkey%EB%A5%BC-%EC%A0%81%EC%9A%A9%ED%95%B4%EB%B3%B4%EC%9E%90)Welcome to write articles about Fixture Monkey!
Please let us know if you'd like to share your post.## License
```
Copyright 2021-present NAVER Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```