How to get your first 50 users with RxPeople

… a reactive android Library for generating random user data :)

When developing an application, you would be wise to test it. You might test it for correctness and you might test it for load. Both of these situations benefit from having a large body of data that is coherent, but one that would be automatically generated. RxPeople is an attempt at making this problem smaller.

Why is test data important?

If you’re developing an application, you’ll want to make sure you’re testing it under conditions that closely simulate a production environment. If you’re hand-entering data into a test environment one record at a time, you’re never going to build up the volume and variety of data that your app will accumulate in a few days in production. Worse, the data you enter will be biased towards your own usage patterns and won’t match real-world usage, leaving important bugs undiscovered.

Example of what you can achieve with RxPeople

Why does realistic data matter?

When your test data is composed by realistic looking data, you’ll be more engaged as a tester. When you demonstrate new features to others, they’ll understand them faster. Real data is varied and will contain characters that may not play nice with your code, such as apostrophes, or unicode characters from other languages. Testing with realistic data will make your app more robust because you’ll catch errors that are likely to occur in production before release day.

Usage

Getting 100 random people from random countries:

RxPeople.with(context)

.amount(100)

.intoObservable()

.subscribe(users -> {

// todo: what you please

});

Being specific: Getting 50 women from Brazil:

RxPeople.with(context)

.amount(50)

.nationality(Nationality.BR)

.gender(Gender.FEMALE)

.intoObservable()

.subscribe(users -> {

// todo: what you please

});

Useful info

It’s really important to set both .subscribeOn() and .observeOn() it’s the only way to guarantee the thread which the request is gonna run at (if you don’t know why I’m asking this read my blog post Party tricks with Rxjava);

to set both .subscribeOn() and .observeOn() it’s the only way to guarantee the thread which the request is gonna run at (if you don’t know why I’m asking this read my blog post Party tricks with Rxjava); Want to convert my FakeUser class into your own UserClass? use a flatMap to transform it before subscribing to the Observer, easypeasy;

An example.json of a complete FakeUser can be found here;

of a complete FakeUser can be found here; Don’t forget to check the Sample project.

Install

Add the dependency in the form:

dependencies {

compile 'com.cesarferreira.rxpeople:rxpeople:+'

}

Thanks to