Konveyor

General

Category
Free
Tag
Data Generators
License
Apache License, Version 2.0
Min SDK
1 (Android 1.0)
Registered
Sep 17, 2018
Favorites
0
Link
https://github.com/vacxe/Konveyor
See also
RxPeople
Randomizer
Faker
Random Beans
rog

Additional

Language
Kotlin
Version
1.0.3 (Dec 16, 2018)
Created
Aug 15, 2018
Updated
Dec 16, 2018
Owner
Konstantin Aksenov (Vacxe)
Contributors
lolevsky
Konstantin Aksenov (Vacxe)
imnosov
dananas
4
Activity
Badge
Generate
Download
Source code

Announcement

Konveyor

Konveyor is a library for generating Data classes with random values.

Motivation

From time to time, when you implement a test, you need an instance of object. Creating an instance manually takes a lot of time and it might be boring. It's even worse if object contains nested objects. It makes your test a bit littered.

How to use Konveyor

For example you have some class like this

data class PrimitiveDataClass(val int: Int,
                              val double: Double,
                              val byte: Byte,
                              val short: Short,
                              val long: Long,
                              val float: Float,
                              val boolean: Boolean,
                              val char: Char,
                              val string: String,
                              val charSequence: CharSequence)

Just call this:

val primitiveDataClass: PrimitiveDataClass = randomBuild()

And all fields are automatically filled up:

PrimitiveDataClass(int=-160837378, double=0.2543439936127936, byte=125, short=7553, long=8930811805778341874, float=0.9110602, boolean=false, char=2, string=String_212195448, charSequence=String_1391234678)

All boolean will be false by default

Special cases

Konveyor generates for you every class which has primitives in base. But sometimes, we have to create classes with interfaces and with some irregular cases. We can resolve this issue by using ObjectResolver:

val resolver = ObjectResolver()
resolver(MyInterface::class.java, { MyInterfaceImpl() })

val nestedInterfaceDataClass: NestedInterfaceDataClass = randomBuild(resolver = resolver)

Compatibility with Java

Of course, you can use Konveyor with Java:

PrimitiveDataClass primitiveDataClass = KonveyorKt.randomBuild(PrimitiveDataClass.class);

Download

Maven:

<dependency>
  <groupId>com.github.vacxe</groupId>
  <artifactId>konveyor</artifactId>
  <version>latest version</version>
  <type>pom</type>
</dependency>

or Gradle:

repositories {
    jcenter()
}

dependencies {
    compile 'com.github.vacxe:konveyor:latest version'
}
Enjoy your build with Konveyor!