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

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.



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


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

public class FooTest {

    @Rule public JUnitForger forger = new JUnitForger();

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


The full documentation can be read on ReadTheDocs.


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

Latest Release : 0.11 (2019/07/18)

  • Add forgery to create a random substring of a String (eg: aSubstring("Hello world"))

For more information, read the Changelog.


Xavier F. Gouchet – @xgouchet

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


About Me
Google+: Trinea trinea
GitHub: Trinea