6

What I'm looking for is some library like Perl's Data::Faker, Ruby's factory_girl. Something that allows me to generate random Strings, Dates, ... for testing.

I saw this other question. But I want something that has been used by someone with Android.

Community
  • 1
  • 1

3 Answers3

5

I tried java-faker, jFairy - they don't work on android. So I find fluttercode.datafactory - it's ok for android. Add following to your app build.gradle to use it:

compile 'org.fluttercode.datafactory:datafactory:0.8'

Usage example: http://java.dzone.com/articles/generate-test-data-datafactory

IliaEremin
  • 3,338
  • 3
  • 26
  • 35
0

I've recently developed a library that can be used for generating test data for your applications in a programatic way.

Take a look at MockNeat: https://github.com/nomemory/mockneat

There are also two detailed examples on the wiki page:

  1. Creating CSV with test data

  2. Populating a SQL Schema with test data

Andrei Ciobanu
  • 12,500
  • 24
  • 85
  • 118
0

From the link that you gave, it seems that you are looking for Mock libraries that could be used in Android.

This article, written by some Google engineers, use PowerMock library to do their unit tests in Android. You might want to try it out and follow the steps in the article to have your test up and running.

Ibrahim Arief
  • 8,742
  • 6
  • 34
  • 54
  • Not exactly. What I need right now is something that generates basic data. For example, I want to test the creation of several Person objects and I want something that generates random names instead of hardcoding the strings. – Tanausú González Feb 08 '12 at 13:28
  • Wow, totally different with what the link had then. =/ Well, since Perl's Faker is open-sourced, and it only create random permutation of the hardcoded data, why don't you lift the data from its source (e.g.: http://cpansearch.perl.org/src/WSHELDAHL/Data-Faker-0.08/lib/Data/Faker/Name.pm) and create your own faker library. Might be even quicker than searching for appropriate libraries in the Internet. – Ibrahim Arief Feb 08 '12 at 14:21
  • @TanausúGonzález: This question/answers may help you http://stackoverflow.com/questions/6362683/does-a-fake-data-generator-exists-in-java – Blue Smith Mar 28 '13 at 10:09