Popularity
2.0
Declining
Activity
8.3
-
35
3
0

Programming language: Kotlin
License: MIT License
Tags: Tests    
Latest version: v1.0.1

RandomGenKt alternatives and similar libraries

Based on the "Tests" category.
Alternatively, view RandomGenKt alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of RandomGenKt or a related project?

Add another 'Tests' Library

README

RandomGenKt

Initialize instances of any class with generated data.

Version - RandomGenKt Version - DataSource Build Status License

Example

This is a Kotlin port of the Java library designed to generate random instances of any class.

This is great for demoing your app with interesting content, manually testing it with varying data, and even populating it with smart, random generated data in production.

Install

In your build.gradle, add the following:

dependencies {
    implementation("com.mitteloupe:randomgenkt:1.0.1")
}

To include the default data generators, also include

dependencies {
    implementation("com.mitteloupe:randomgenkt.datasource:1.0.1")
}

Note: To add the BinTray repository in your maven repositories, also add the following:

repositories {
    maven {
        url "https://dl.bintray.com/shadowcra/RandomGenKt"
    }
}

Usage

Kotlin

val randomGen = RandomGen.Builder<ObjectClass>()
    .ofClass<ObjectClass>()
    .withField("id")
    .returningSequentialInteger()
    .withField("uuid")
    .returningUuid()
    .build()

Java

RandomGen<ObjectClass> randomGen = new RandomGen.Builder<ObjectClass>()
    .ofClass(ObjectClass.class)
    .withField("id")
    .returningSequentialInteger()
    .withField("uuid")
    .returningUuid()
    .build();

This will create a RandomGen instance producing ObjectClass instances with sequential IDs and random UUIDs.

To use the newly generated RandomGen, simply call:

Kotlin

val instance = randomGen.generate()

Java

ObjectClass instance = randomGen.generate();

What's New?

The Kotlin version adds the following:

  • Support for fields with lazy init
  • Lambdas
  • ofClass<Type>() instead of ofClass(Type::class.java)

Created by

Eran Boudjnah

License

MIT © Eran Boudjnah


*Note that all licence references and agreements mentioned in the RandomGenKt README section above are relevant to that project's source code only.