Introduction to Zucchini

If you are familiar with a test framework Cucumber, you need to know that there's a new kid on the block by the name of Zucchini. Zucchini has been developed by brilliant engineers at Comcast Silicon Valley Innovation Center. Essentially, it is a wrapper around Cucumber JVM with some extra nifty features. The two that come to mind are:

  • Test Contexts
  • Mutithreading

In this post, I'll explain what above features are and will walk you through on how to get started using this great framework.

Test Contexts

First, let's start with Test Contexts. TestContext is a mechanism for sharing data between test steps. While Cucumber JVM allows for passing variables from step to step, it is only possible via class variables of the same class. Based on this Stack Overflow thread, my previous statement is not exactly true, but it looks like a hassle to get it to work. With Zucchini's TestContext feature, you are 1 command away from getting your shared variable from any glue class. Here's a basic usage of TestContext:

// Save a value
TestContext.getCurrent().set("variableName", "variableValue");
 
// Retrieve a value
Object myObj = TestContext.getCurrent().get("variableName");

Under the covers, TestContext is a simple Map that lives throughout the entire test execution cycle. This means that data can be shared across multiple scenarios!

Multithreading

Another great feature of Zucchini is multithreading. Zucchini allows running same set of tests across multiple targets (mobile devices, web browsers) simultaneously. How cool is that?

The way zucchini is able to do this is by leveraging TestContext concept. When tests start, Zucchini creates a thread per TestContext created (I will show how to create a test context later on in this post). It is usually the case that a reference to the test target is added to the TestContext. This way, when you need to interact with your test target, all you need to do is something like this:

  ((SomeCoolTarget) TestContext.getCurrent().get("name of the target")).sendCommand("my cool command");

Reporting

Since Zucchini is an extension of Cucumber, all formatters should be available in Zucchini as well. If no formatter is specified via @CucumberOptions annotation, Zucchini is going to auto-generate a HTML report using a template made by MasterThought

Conclusion

So, this is a quick and dirty overview of what Zucchini is and what features it brings to your test frameworks.
I know that this post fell a little short and did not include any information on how to get up and running with Zucchini. Please stay tuned and I'll make another post very soon that will demonstrate how to create a new Zucchini project

As always, questions and comments are welcomed!

Comments