Elmyr

Project Url: xgouchet/Elmyr
Introduction: A utility to make Kotlin/Java tests random yet reproducible
More: Author   ReportBugs   
Tags:

Elmyr is a Kotlin library providing tools to generate “random” values, specifically usefull for tests

license Kotlin 1.2.10

Release Documentation Status Build Status codecov

Being an adept of testing code, I write a lot of tests. One thing I noticed is that in my tests, my fake / test data always look the same. My user names are always “Bob” and “Alice”, aged 42 or 69, with userId 4816152342 or 24601, and eating “spam”, “eggs” and “bacon”.

The problem is, the more test I write, the less I'm confident in my fake values, because they're always the same.

This is where Elmyr kicks in, allowing you to create fake/fuzzy data based on a few constraints, making your test data random, and yet reproducible.

Usage

Gradle

    repositories {
        maven { url "https://jitpack.io" }
    }
    dependencies {
        testCompile 'com.github.xgouchet:Elmyr:0.9'
    }

JUnit

Elmyr provides a JUnit Rule that you can use to make your tests reproducible.

public class FooTest {

    @Rule public JUnitForger forger = new JUnitForger();

    @Test
    public void shouldDoSomething(){
        int base = forger.aPositiveInt();
        int result = square(base);
        assertThat(result).isEqualTo(base * base);
    }
}

Documentation

The full documentation can be read on ReadTheDocs.

Contributing

Contribution is fully welcome. Before submitting a Pull Request, please verify you comply with the following checklist :

  • [x] All public classes, methods and fields must be documented
  • [x] All code must be unit tested (duh…)
  • [x] All code should be useable with and without the Android SDK, from Java and Kotlin

Release History

Last Release: 0.9.1 (2018/11/09)

  • Handle negated character set in regex (eg : aStringMatching("[^a-f]"))

For more information, read the Changelog.

Meta

Xavier F. Gouchet – @xgouchet

Distributed under the MIT license. See LICENSE.md for more information.

https://github.com/xgouchet/Elymr

Support Me
Apps
About Me
Google+: Trinea trinea
GitHub: Trinea