Telerik blogs
Test StudioT Light_870x220

Random data testing has been around for ages and every now and then our Test Studio support team gets a request like this:

How can I input random data into my test run?

At a first glance this seems to be a feature that's lacking in Telerik Test Studio, and going over the documentation will yield some results like this one here. Now to the trained user this is a straight solution – create a coded step and do it, you know, the “coding QA engineer’s” way. And this is fine.


But then comes the next field, the next value. “Oh this is a number, but I need email, telephone… etc.” Then you will probably think about reusability but there is a pretty big chance that eventually you will have this little code noodle monster spread across the entire project.


So, how we can prevent that? I’ve been tinkering with “Any-.Net”, a simple old framework for generating all sorts of random data and it seems to be solving the issue pretty well.

So, let’s integrate it in Test Studio:

1. Download “Any-.Net” and add it as a script reference to your Test Studio project:


2. Create a simple test that will act as a reusable container for random data. I will call it “SetRandomValues.”


3. Open the “SetRandomValues” test and add a coded step to it:


4. Time to integrate the Any-.Net framework into our project. This will be the only piece of code that you’ll ever require:

[CodedStep(@"New Coded Step")]
        public void SetRandomValues_CodedStep()
            this.SetExtractedValue("randomMail", Any.Any.EmailAddress());
            this.SetExtractedValue("randomPass", Any.Any.Word(8));
            this.SetExtractedValue("randomInt", Any.Any.Integer(0, 100));

Now whenever you need a random value you can simple reference the “SetRandomValues” as test as a step:


5. Finally, bind your “Set” actions to the random value(s). here is an example for a “SetText” step which inserts a text into a username field:


That’s it! Having a single test as a random value generator reduces complexity and maintenance. On top of that all values are bound via the built-in functionality, so it doesn’t require any coding.

If you want to try this you can start a free, fully functional 30-day trial:

Try Test Studio

Nikolay Atanasov
About the Author

Nikolay Atanasov

Nikolay was an Engineering Manager on the Test Studio team.

Related Posts


Comments are disabled in preview mode.