-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Faker #313
Comments
Are you talking about this? It seems to be unmaintained, but if you think it's still valid is ok for me. Can you provide any additional info, such as a code snippet of how you currently use it, or how you would like to use it in Spectrum? Or is the snippet in their README enough? Faker faker = new Faker();
String name = faker.name().fullName(); // Miss Samanta Schmidt
String firstName = faker.name().firstName(); // Emory
String lastName = faker.name().lastName(); // Barton
String streetAddress = faker.address().streetAddress(); // 60018 Sawayn Brooks Suite 449 Based on this, we could just inject the faker:
locale: en_US
random: 24 so that the injected Faker is configured accordingly. What do you think? |
Yes, this makes sense |
Ok, I'm gonna work on it in the next days. Keep you posted. |
Looking at Javafaker issues, I found many in which they talk about Datafaker as a replacement, for example this one. Basically, Datafaker is a fork whose api is compatible with Javafaker, and is actively maintained, so no CVEs and new features. For completeness, here's the Datafaker's docs. For the reasons above, I chose Datafaker. Constructors are the same, they take (optionally) a Locale and a Random instance. So, it can be configured in Spectrum via this node: faker:
locale: it
random: 24 Here you can find the currently supported locales. The Spectrum's internal default is this: faker:
locale: en
random: null Meaning if you need no random seed and the english locale, you can leverage the default and avoid configuring it explicitly. I added a couple tests to show how to use it. Basically, you just need to leverage the injected @Test
void test() {
String name = faker.name().fullName(); // Miss Samanta Schmidt
String number = faker.numerify("##");
String anotherNumber = faker.expression("#{numerify '##'}");
...
} You can find the implementation in PR #325. Tell me if you think something is missing or wrong. Otherwise, if it's ok for you, I'll prepare a new release with it. Please let me know |
Feature description
Add faker for demo data generation
Describe why this should be added to Spectrum
Fake helps is demo test data generation which can save a lot of time
Additional context
The text was updated successfully, but these errors were encountered: