Logo-English

GR

 

 

QA AUTOMATION ENGINEER

 

Parameterization Tools: TestSpicer

Some time ago I talked here about parameterization (or randomization) and why it is important when we are automating. Back then I talked about some tools that we can use to make our tests more random. In my first post about those tools I talked about Generate Data a web tool that basically generates the data and you save it in a file to use it afterwards. In this post, I will talk about TestSpicer a tool that pretty much does the same thing but in a better way by letting us get data during execution.

TestSpicer

 

How does it works?

TestSpicer has an API that we can call from our test code. So when our tests are running and are in need of data, they can just call the API for the necessary info, gets it an uses it. It is easy to use. Here we can see the documentation and we can actually make calls for each endpoint from their web. In there you can see how to call it, what kind of info each endpoint brings and how do they serve it. The advantage TestSpicer has over Generate Data is that we don't need to generate files and waste hard drive saving it, just to dispose it when we finish to use the whole file. TestSpicer gives you the oportunity to generate data "on the fly" and use it. Let's see an example.

Let's say that I am going to register a new user in my Website that contains the following info in the register form:

Firstname

Lastname

Email

Password

What I need to do first is to start the session with TestSpicer (to mark when our test has started) and then simply use variables and make the call from them to the needed endpoint. At the end, we just need to close the session with TestSpicer, in Ruby:

load "TestSpicerAPI.rb"

sessionId = start_test('Ruby', 'Testing', 'example', 'This is an example', 'Something', 'None')

name = get_random_name(sessionId)['firstname']
lastname = get_random_name(sessionId)['lastname']
email = get_random_email(sessionId)['email']
password = get_random_alphabet_string(sessionId, "10")['string']

puts name
puts lastname
puts email.downcase
puts password

finish_test(sessionId)

 

In Python: 

import TestSpicerAPI

testApi = TestSpicerAPI.TestSpicerAPI()

sessionId = testApi.startTest('Project', 'Suite', 'Test', 'This is a test', 'Functional Area', 'Risk Coverage')

email = testApi.getRandomEmail(sessionId)['email']
name = testApi.getRandomName(sessionId)['firstname']
lastname = testApi.getRandomName(sessionId)['lastname']
password = testApi.getRandomAlphaNumeric(sessionId, 10)['string']

print name
print lastname
print email
print password

finishTest = testApi.finishTest(sessionId)

 

You can see my little service to call TestSpicer in my Github. It is not completed with all the endpoints from TestSpicer but is easy to follow and add more.