Spice Up Your Test Automation With Test Spicer

Spice up your Test Automation with Test Spicer

In manual testing, we play with our application by running the same tests with different input data. This helps testers to increase test coverage and uncover unexpected bugs. This is not true for automation, where we usually hard code the data we wanted to test into our test function. This reduces the efficiency and effectiveness of our automation scripts which keep executing a scenario again and again with the same set of data. As a result, they rarely find bugs after few executions and bugs that are not in the script execution path or data that we are using in the automation. However, if we add randomly generated data, just like manual testing, we increase our chances of finding new bugs or interesting information with every execution. Test Spicer helps to add this spice to our automation.

Test Spicer

Test Spicer provides a kind of utility to generate random data and makes it easier to explore something new in every test run. It helps to improve the sample data size as its every execution is different than the earlier ones. It also improves the probability of finding defects by using randomly generated data in every run. It leads the project on the path of Effective Testing.


Test Automation Scripts with Varied set of data means Effective Testing

What it does?
Test Spicer is a restful web service. To use TestSpicer, a user needs to sign up on www.testspicer.com website. The user is then receives an API key. User can then call the appropriate API depending on his requirement. Test Spicer returns the data in either a JSON or XML format. This data can then be used for testing purpose.


  • A restful interface
  • Quickly generate random test data

Setting up

Let's write our first test now… Here we are using Selenium Webdriver with Java. We can use Test Spicer with any platform, tool or language. In this test we have chosen Xebia Contact Us form as the test site. The contact us form contains different input fields that accept different kinds of data. Eg: Name field accepts string, Phone field accepts numbers, Email field accepts email and Message field accepts a long paragraph. We want the automation script to enter a different set of data every time. This can be done by first writing code to call the Test Spicer RESTful API.

Writing code to call the API

 public class JavaNetURLRESTFulClient { String targetURL; Map map;

    public String getTargetURL(String input){
            targetURL = "http://testspicer.com/restapi/v0.1/string/en/10";
        else if (input.equals("phone"))
            targetURL = "http://testspicer.com/restapi/v0.1/telephone?countrycode=UK";
        else if(input.equals("email"))
            targetURL = "http://testspicer.com/restapi/v0.1/email?domain=com&length=20";
        else if(input.equals("para"))
            targetURL = "http://testspicer.com/restapi/v0.1/lorem?language=en";
        return targetURL;

    public Map getRandomData(String input){
        try {

            URL restServiceURL = new URL(targetURL);

            HttpURLConnection httpConnection = (HttpURLConnection) restServiceURL.openConnection();

            if (httpConnection.getResponseCode() != 200) {
                throw new RuntimeException("HTTP GET Request Failed with Error code : "
                        + httpConnection.getResponseCode());

            map = new Gson().fromJson(IOUtils.toString(httpConnection.getInputStream(),"UTF-8"), Map.class);
        } catch (MalformedURLException e) {
        } catch (IOException e) {
        return map;


How it works:

In the above code, we issue a GET request to the end point like “string/en/10” and get 10 character long string. If we want a different length, we just need to modify the length to the desired value.

*Writing Selenium Webdriver Test *

 public class ContactUsTest { public static void main (String[] args) throws InterruptedException{ Map map;

        WebDriver driver = new FirefoxDriver();

        WebElement name = driver.findElement(By.id("name"));
        WebElement contact_no = driver.findElement(By.id("phone"));
        WebElement email = driver.findElement(By.id("email"));
        WebElement message = driver.findElement(By.id("message"));

        JavaNetURLRESTFulClient obj = new JavaNetURLRESTFulClient();

        map = obj.getRandomData("alphabetString");

        map = obj.getRandomData("phone");

        map = obj.getRandomData("email");

        map = obj.getRandomData("para");



Steps to run the tests

We just run our selenium test as a Java application. It should spawn a browser and start executing the test with a given set of data. In the second run, it should type a different set of data.

You should get something like this: Xebia_Contact_Us


  • No need to write code to generate random data
  • Increase coverage of tests

TestSpicer helps to provide test ideas to make sure that apparent things related to quality are never missed.

Similar tools in the market selite

*References * http://testspicer.com/

Leave a Reply

Your email address will not be published. Required fields are marked *