ProductPromotion
Logo

Kotlin

made by https://0x3d.site

GitHub - HelloCuriosity/model-forge: Model Forge is a library to automate model generation for automated testing
Model Forge is a library to automate model generation for automated testing - HelloCuriosity/model-forge
Visit Site

GitHub - HelloCuriosity/model-forge: Model Forge is a library to automate model generation for automated testing

GitHub - HelloCuriosity/model-forge: Model Forge is a library to automate model generation for automated testing

Model Forge 🔥🔨

Build Status codecov License Contributor Covenant Sonatype Nexus (Snapshots) Awesome Kotlin Badge

About

Model Forge is a library to automate model generation for automated testing:

  • unit
  • integration
  • etc.

Getting Started

Gradle Setup

dependencies {
    testImplementation("io.github.hellocuriosity:model-forge:1.5.0")
}
dependencies {
    testImplementation 'io.github.hellocuriosity:model-forge:1.5.0'
}

Feeling Adventurous 💥

If you're feeling adventurous you can be on the cutting edge and test a snapshot:

repositories {
    maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots/")
}

dependencies {
    testImplementation("io.github.hellocuriosity:model-forge:1.5.0.xx-SNAPSHOT")
}
repositories {
    maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
}

dependencies {
    testImplementation 'io.github.hellocuriosity:model-forge:1.5.0.xx-SNAPSHOT'
}

Define your model

data class Employee(
    val id: Long,
    val name: String,
    val dob: Instant,
)

Generate model

val forge = ModelForge()
val testObject = forge.build<Employee>()

or by delegating

val testObject: Employee by forgery()

You can create different sized lists by specifying the number of elements.

val forge = ModelForge()
val list = forge.buildList<TestObject>(3)

or by delegating

val testObjects: List<TestObject> by forgeryList()

Custom Provider

While Model Forge aims to fully automate model generation, you may run into an instance where you need to customize your data. This is easily achievable by defining a custom provider and adding it to the forge.

Define your provider

val testProvider: Provider<TestObject> = Provider {
    Employee(
        id = 15L,
        name = "Josh",
        dob = Instant.ofEpochMilli(1315260000000)
    )
}

Add your provider to the forge

forge.addProvider(TestObject.class,testProvider);

or Kotlin

forge.addProvider(testProvider)

Inline your provider(s)

Alternatively you can add your forgery providers inline


val forge = ModelForge().apply {
    addProvider {
        Employee(
            id = 2L,
            name = "Hendrik",
            dob = Instant.ofEpochMilli(1574486400000)
        )
    }
}
val employee by forgery<Employee>(forge)

Supported Types

Model Forge currently supports the auto generation for the following types:

Types

  • Boolean
  • Byte
  • Calendar
  • Char
  • Date
  • Double
  • Enums
  • File
  • Float
  • Int
  • Instant
  • Long
  • Short
  • String
  • UByte
  • UInt
  • ULong
  • UShort
  • UUID

Collections

  • List
  • Map
  • Set

Can't find your data type? Feel free to create a pull request or open an issue 🪂

Contributing

Thanks for showing your interest in wanting to improve Model Forge. Before you get started take a look at our code of conduct and contribution guides 🙌

Contributors

If you contribute to Model Forge, please feel free to add yourself to the list!

  • Kyle Roe - Maintainer
  • Adriaan Duz - Contributor
    • Kotlin class definitions
    • Forgery and forgeries property delegate
    • Reified inline extension functions
  • Alicja Kozikowska - Contributor
    • Fix StringProvider treatment of invalid wordCount

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory