how to make Data generator to execute every test for random data
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how to make Data generator to execute every test for random data
Hi,
I need to generate random data and with diffren size every time I run test.
how can I do it?
I saw post that suggest to generate once a large file and then take only part of it but I need to define diffrent parameters for the file.
is there any way to configure and generate data generator from script or any other option?
Best regards,
Ran
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
What kind of data would you like to generate? Random strings of characters? Random dates? Random numbers? And would you require multiples of these?
Mo
Have an awesome day!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have test that I need to generate random passwords, other test that I need random strings and in the last test I need random numbers.
I don't want that in my test any random option will repeat twice.
Ran
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To create random passwords (Strings), and numbers you can use the RandomStringUtils: Documentation here
You'll then want to store them into custom properties to then be used in your test requests.
Example:
import static org.apache.commons.lang3.RandomStringUtils.* //if you have a property step you can use it to store them, otherwise you can store them at test case level def randomProperties = testRunner.testCase.getTestStepByName("randomProperties") def randomPassword = randomAlphanumeric(8,21) // arguments: minimum length, max length (so a string between 8 and 20 characters) def randomString = randomAlphanumeric(8,21) def randomNumber = randomNumeric(5) // random numbers of length 5 randomProperties.setPropertyValue("randomPassword",randomPassword) randomProperties.setPropertyValue("randomString",randomString) randomProperties.setPropertyValue("randomNumber",randomNumber)
you can then access these properties in your requests with
${randomProperties#<propertyName>}
Hope this helps,
Mo
Have an awesome day!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In case you want to generate your data outside of TestComplete pre-test, there are tools available that will do that for you. Depends on the quantity of data you need, if you need to mask fields for legal reasons, etc - sometimes the cost of a data generation tool is less than the cost of you writing your own code to create you test data.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there anyway to use it with scripts?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes... as indicated... you can utilize external utilities (JAR files, .NET assemblies, etc) in your TestComplete scripts and generate your data that way.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As far as I understand, I can't and I must use external library for that.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is correct. The data generator built in to TestComplete is for creating static data (randomized upon creation) to include in a test scenario. It does not have any external object/method to access at run-time for generating data. Hence all the suggestions for seeking outside modules to assist in that data generation.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
