All Projects → appmattus → Kotlinfixture

appmattus / Kotlinfixture

Licence: other
Fixtures for Kotlin providing generated values for unit testing

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Kotlinfixture

Faker
Faker is a pure Elixir library for generating fake data.
Stars: ✭ 673 (+615.96%)
Mutual labels:  hacktoberfest, test, testing-tools
Kiwi
the leading open source test management system
Stars: ✭ 607 (+545.74%)
Mutual labels:  hacktoberfest, testing-tools
Haskell Hedgehog
Release with confidence, state-of-the-art property testing for Haskell.
Stars: ✭ 584 (+521.28%)
Mutual labels:  test, testing-tools
Cypress
Fast, easy and reliable testing for anything that runs in a browser.
Stars: ✭ 35,145 (+37288.3%)
Mutual labels:  test, testing-tools
Carina
Carina automation framework: Web, Mobile, API, DB
Stars: ✭ 549 (+484.04%)
Mutual labels:  test, testing-tools
Vue Testing Library
🦎 Simple and complete Vue.js testing utilities that encourage good testing practices.
Stars: ✭ 567 (+503.19%)
Mutual labels:  test, testing-tools
Cli Prompts Test
Write e2e tests for CLI apps with ease
Stars: ✭ 17 (-81.91%)
Mutual labels:  hacktoberfest, test
Isolator
Detect non-atomic interactions within DB transactions
Stars: ✭ 362 (+285.11%)
Mutual labels:  hacktoberfest, testing-tools
Elmyr
A utility to make Kotlin/Java tests random yet reproducible
Stars: ✭ 68 (-27.66%)
Mutual labels:  hacktoberfest, test
Assert
A collection of convenient assertions for Swift testing
Stars: ✭ 69 (-26.6%)
Mutual labels:  test, testing-tools
Pystdf
Python module for working with STDF files
Stars: ✭ 74 (-21.28%)
Mutual labels:  hacktoberfest, test
Mocha
☕️ simple, flexible, fun javascript test framework for node.js & the browser
Stars: ✭ 20,986 (+22225.53%)
Mutual labels:  test, testing-tools
Tparse
CLI tool for analyzing and summarizing go test output. Pipe friendly. CI/CD friendly.
Stars: ✭ 445 (+373.4%)
Mutual labels:  test, testing-tools
Httptest
Qiniu httptest utilities
Stars: ✭ 571 (+507.45%)
Mutual labels:  test, testing-tools
Testfx
MSTest V2 framework and adapter
Stars: ✭ 391 (+315.96%)
Mutual labels:  test, testing-tools
Snapper
Bringing Jest-esque Snapshot testing to C#
Stars: ✭ 85 (-9.57%)
Mutual labels:  test, testing-tools
Zora
Lightest, yet Fastest Javascript test runner for nodejs and browsers
Stars: ✭ 356 (+278.72%)
Mutual labels:  test, testing-tools
Unity Actions
Github actions for testing and building Unity projects
Stars: ✭ 358 (+280.85%)
Mutual labels:  hacktoberfest, test
Mts
Project of Multi-protocol Test Tool opensourced by Ericsson
Stars: ✭ 34 (-63.83%)
Mutual labels:  test, testing-tools
Testcafe
A Node.js tool to automate end-to-end web testing.
Stars: ✭ 9,176 (+9661.7%)
Mutual labels:  test, testing-tools

= KotlinFixture Appmattus Limited [email protected] :toc: preamble :toc-title: Contents :homepage: https://github.com/appmattus/kotlinfixture ifdef::env-github[] :tip-caption: 💡 :note-caption: ℹ️ :important-caption: ❗️ :caution-caption: 🔥 :warning-caption: ⚠️ endif::[] :link-appmattus: https://github.com/appmattus/kotlinfixture[KotlinFixture]

https://search.maven.org/search?q=g:com.appmattus.fixture[image:https://img.shields.io/maven-central/v/com.appmattus.fixture/fixture[Maven Central]] https://github.com/appmattus/kotlinfixture/actions[image:https://github.com/appmattus/kotlinfixture/workflows/CI/badge.svg[CI status]] https://codecov.io/gh/appmattus/kotlinfixture[image:https://codecov.io/gh/appmattus/kotlinfixture/branch/main/graph/badge.svg[Coverage status]] link:LICENSE.md[image:https://img.shields.io/badge/License-Apache%202.0-blue.svg[License]]

A tool to generate well-defined, but essentially random, input following the idea of constrained non-determinism.

== Getting started

Include the following dependency in your build.gradle.kts file:

[source,kotlin] .build.gradle.kts

testImplementation("com.appmattus.fixture:fixture:")

Simply create a fixture and invoke it with the type to be generated:

[source,kotlin]

val fixture = kotlinFixture()

// Generate a list of strings val aListOfStrings = fixture<List>()

// Nulls are supported val sometimesNull = fixture<Int?>()

// Create instances of classes // Optional parameters will be randomly used or overridden data class ADataClass(val value: String = "default") val aClass = fixture()

// Abstract classes will pick a sub-class at random // This could be a Byte, Double, Long, Float, Int or Short val anyNumber = fixture()

// Pick randomly from a list val randomStringFromTheList = fixture(listOf("Cat", "Dog", "Horse")) val anotherRandomIntFromAList = fixture(1..5)

You can also generate an infinite sequence of a type, which you can then filter:

[source,kotlin]

val fixture = kotlinFixture()

val intSequence = fixture.asSequence()

// Standard Kotlin sequence functions can then be applied before using // the sequence through an iterator for access to the next() function.

// For example, you can filter values val oddIterator = intSequence.filter { it.absoluteValue.rem(2) == 1 }.iterator() val oddNumber = oddIterator.next() val anotherOddNumber = oddIterator.next()

// Or, ensure it returns only distinct values enum class XYZ { X, Y, Z } val enumIterator = fixture.asSequence().distinct().iterator() val aDistinctValue = enumIterator.next() val anotherDistinctValue = enumIterator.next()

[WARNING]

The sequence can hang indefinitely if the applied operators prevent the generation of new values. For example:

  • distinct will hang if we exhaust all available values. A good practice is to add a take(count) which will throw a NoSuchElementException if we try to generate more values.
  • filter that can never be fulfilled e.g. filter { false } ====

== Configuration options

Everything can be customised, see link:fixture/configuration-options.adoc[configuration options] for more details.

link:fixture/advanced-customisation.adoc[Advanced engine customisation] is also possible if the above options are not enough.

== Kotest integration: property based testing

The library provides {link-appmattus} powered property based testing for https://github.com/kotest/kotest/[Kotest].

See link:fixture-kotest/README.adoc[Kotest integration] for more details.

== Java Faker integration: pretty data

Generate values with a closer match to real data using http://dius.github.io/java-faker/[Java Faker].

See link:fixture-javafaker/README.adoc[Java Faker integration] for more details.

== Generex integration: regex to random string

To generate a random string from a regular expression, look no further than the Generex integration.

See link:fixture-generex/README.adoc[Generex integration] for more details.

== Related projects

Please take a look at the feature link:fixture/comparison.adoc[comparison with related projects].

== Contributing

Please fork this repository and contribute back using https://github.com/appmattus/kotlinfixture/pulls[pull requests].

All contributions, large or small, major features, bug fixes, additional language translations, unit/integration tests are welcome.

== License

link:LICENSE.md[image:https://img.shields.io/badge/License-Apache%202.0-blue.svg[License]]

Copyright 2020 Appmattus Limited

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 https://www.apache.org/licenses/LICENSE-2.0[https://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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].