Are you looking for a quick, easy and flexible way to create JSON objects to test your JSON service? Or maybe a tool to mock server responses to test some JavaScript browser code? If so, you might be interested in Popcorn.
Popcorn is a JavaScript embedded DSL design to generate any kind of JSON object. It comes with a basic set of generators for most common JavaScript types, and combinators to build new generators for any kind of data. With Popcorn thousands of test cases can be expressed in just few lines of code, which makes it a great driver for data-driven test engines. Let’s go for a quick tour.
First generator (try it):
// Load modules you like to use.
with(Popcorn.Core) {
with(Popcorn.Common) {
// Define the base test case.
var toy = {
name : 'Woody',
rank : 1,
type : 'cowboy'
};
// Assign generators to attributes you like to alter.
var generator = {
name: list('Buzz', 'Slinky')
rank : range(2, 4)
};
// And run it!
var results = generate(generator, toy);
}
As you would expect, range generates integers from 2 to 4 and lists the names ‘Buzz’ and ‘Slinky’. When executed with generate(), this generator object creates six different result objects representing all combinations between the id and user values.
list() and range() overwrite the values of the base object. append() and prepend() for example use the base object value:
var p = prepend('Hello ');
p('Woody'); // returns 'Hello Woody'
p('Buzz'); // returns 'Hello Buzz', etc.
Some generators accept other generators or generator arrays as arguments. For example append(g) executes the generator g and appends the result to the input value:
var r = random().int(), // random integer generator.
a = append(r);
a('user'); // will return for example 'user42' or 'user573' etc.
If you like to pass a generated value to a generator function that does not accept generators as argument, use chain() function to execute these generators in sequence. For example to build random user names of the form {user}-{random_int} you can define a generator as following:
var r = random().int(),
u = chain(r, function(i) { return append('-' + i); });
u('admin'); // will return for example 'admin-385' or 'admin-712', etc.
chain() executes the generator r and passes the result to the argument function that returns a new generator as result, here the append generator. chain() itself is a generator that can be evaluated or passed to another generator.
The previous example looks quite useful already. We can extract it into a separate library and use it with any other generator, for example:
var randomUser = chain(random().int(), function(i) { return append('-' + i); });
repeat(10, randomUser)('user'); // Creates 10 random user names
Popcorn consists of several independently loadable modules that contain generators for random values of different type, dictionaries, network types and many more. For the complete list of generators see API documentation (project repository) and try popcorn maker demos.
We recently released Studio Fx that enables our customers to rapidly do data driven testing of IP services at unprecedented speeds. We extensively use Popcorn in our product to generate these test cases.
Happy hacking!

Pingback: Twitter Trackbacks for Mu Dynamics Research Labs » Blog Archive » Popcorn - Data Driven Testing with JSON [mudynamics.com] on Topsy.com
Pingback: Mu Dynamics Research Labs » Blog Archive » Hearing noises in your backyard?
Pingback: Mu Dynamics Research Labs » Blog Archive » Announcing blitz.io - and we are hiring!
Pingback: cool caravans
Pingback: guest beds
Pingback: triactol
Pingback: young womens clothing
Pingback: craftsman cladding co uk
Pingback: guaranteed rankings
Pingback: best supplements for muscle gain
Pingback: All New Kia Picanto
Pingback: Dallas Boudoir Photographer
Pingback: Dallas Wedding Photographers
Pingback: Dallas Family Portrait Photographer
Pingback: pre workout supplements
Pingback: Ramtha
Pingback: link
Pingback: best bcaa
Pingback: webcam chat
Pingback: simran possessed
Pingback: Phil Cannella
Pingback: Dr.Shams Eye Care Clinic
Pingback: watch free movies online
Pingback: First Aid at Work course
Pingback: Incense Herbal
Pingback: free apple ipad 3
Pingback: buy Twitter followers for cheap
Pingback: kredyty chwilowki
Pingback: link
Pingback: Yarn Bomb
Pingback: Water softener
Pingback: Bee Pollen
Pingback: oc escorts
Pingback: diamond wedding rings
Pingback: black hairstyles
Pingback: Caribbean Weddings
Pingback: myp2p forum
Pingback: Escort girl Paris
Pingback: Trenton MLs listings
Pingback: motorbike games
Pingback: Wedding photographers in Miami
Pingback: wholesale virgin remy hair
Pingback: uzernamezz
Pingback: bingo game template
Pingback: palomar limo
Pingback: lethbridge marketing
Pingback: fish oil supplements
Pingback: tanie noclegi zakopane
Pingback: dating tips
Pingback: chest coach system
Pingback: what is serotonin
Pingback: mixed martial arts
Pingback: how to scrunch hair with mousse
Pingback: how to get blood out of clothes after washing
Pingback: Calculators
Pingback: commercial inspections
Pingback: URL
Pingback: cholesterol
Pingback: tone butt
Pingback: earn money online
Pingback: Keratin Hair Straightening
Pingback: online dating
Pingback: joomla buch
Pingback: Scott Tucker Payday Loans
Pingback: Scott Tucker Payday Loans
Pingback: Under Armour Baseball Cleats
Pingback: African Mango Reviews
Pingback: travel insurance facts
Pingback: North Carolina retirement communities
Pingback: unlock
Pingback: electric toothbrush reviews
Pingback: best electric shaver
Pingback: how to do magic
Pingback: movies reviews
Pingback: Scott Tucker Racing
Pingback: Scott Tucker CBS
Pingback: cellulite treatment
Pingback: BPO Companies
Pingback: Scott Tucker CBS
Pingback: Scott Tucker CBS
Pingback: lipo 6 side effects
Pingback: e-cig reviews
Pingback: steven cymbrowitz
Pingback: best payday loan
Pingback: Orangatang Balut
Pingback: agrandar el miembro
Pingback: beauty salons
Pingback: boot camp training
Pingback: ecommerce seo
Pingback: treating cold sores
Pingback: unlocked cell phones reviews