Zohhak - JUnit Parameterized

The default support for parameterized tests is one of the greatest weaknesses of JUnit. The situation improved some time ago when JUnit Params was released. Today I would like to present another very interesting tool which makes writing parameterized tests for JUnit a much nicer experience. Ladies and gentlemen, I bring you Zohhak!

Basic Information

Let us take a look at this short snippet of Zohhak-powered code so we know what to expect (the code was copied from Zohhak's website):

    "clerk,      45'000 USD, GOLD",
    "supervisor, 60'000 GBP, PLATINUM"
public void canAcceptDebit(Employee employee, Money money, ClientType clientType) {
    assertTrue(   employee.canAcceptDebit(money, clientType)   );


Who is better suited to present Zohhak to the masses than its creator, Piotr Turski? Let me ask him few questions about this project.

Hello Piotr, could you say few words about yourself?

I'm a lazy java daveloper. My laziness forces me to care about software craftsmanship, QA and a few other buzzwords. Sometimes it lets me turn off my computer a bit earlier

Please introduce Zohhak. What is it good for, what problems does it solve?

Zohhak aims to simplify parameterization of JUnit. Existing solutions are too verbose (and therefore unreadable) or too weak. I tried to create something in the middle. As any other parameterization framework: it allows you to run same test method with many different parameters. What may be unique: you can do it without polluting your tests with tedious code that builds those parameters. and you can use parameters of any type.

And the name? Where does "Zohhak" name come from?

Why zohhak? For the same reason that lombok, java, ganymede or apache.

How does Zohhak differs from competition - i.e. JUnit Params?

JunitParams was my inspiration. Paweł Lipiński (the author) had a great idea. He made parameterized tests very clean and readable. the problem is extensibility.
On the other hand there is this @Parameters annotation of JUnit. It provides all the flexibility you need. But the code gets cluttered with boilerplate stuff. After all, tests should be the cleanest documentation.
Zohhak deals with some of those problems but also has its limitations, eg:

  • you can't read parameters from file nor generate them at runtime,
  • you can't have cartesian product of different sources of parameters,
  • parameters should have short human readable string representation.

I don't think zohhak competes with any of mentioned products. each of them has features that zohhak has not.

Why do you think parameterized tests are so important? What do you use them for?

Tthe most common answer to that question is that "they let you write less". And of course it's true. However i believe the more important is: they let you read less.

What are your plans regarding Zohhak? Is there already some community around it?

Community? Of course, huge! There is me, myself and i. Cmon! The project was released like one weak ago.
The most important thing is to finish the user guide. And now, because of you, i have to do it even faster :)
I'm also waiting for community's feedback - there is no point in developing product used by no one. That's the reason why i decided to release it in such an early stage. I'm also looking for some public CI, gerrit and sonar hosting for zohhak. It's my first open source, i'm a newbie in that area.
But going back to real meat, i want to:

  • add support for custom annotations. that will further reduce amount of boilerplate,
  • add support for other runners: spring, mockito, maybe powermock, maybe junit < 4.5,
  • rewrite runner to make it easy to extend and combine with other runners,
  • add a lot of default coercers,
  • add 'transitive' coercions. it would be nice to allow to write coercion to joda from date, not only from string,
  • add 'partial' coercion. It would be nice to allow to write sth like <2.3, 3.5i> and then write coercion to complex number from two doubles instead of from one string. But this one is just an idea, i still have no clear concept for it.

Piotr, thank you very much for this interview! And good luck with Zohhak development!

Check out FuzzTester

You should check out FuzzTester it does what you want plus more.

Name of this very nice library?

Hi Tomek,

Can you explain the name more? I probably should ask Piotr straightaway, if so, don't mind redirecting me. :-)

Lombok is after red pepper (spice Java).
Java is a blend of coffee.
Apache is an Indian tribe (American Indians, or, as they call them native Americans). And the name came to be from "a patchy" server, since Apache started as patches to other project.
Ganymede is a moon and if it's the Eclipse one - the name is a series of astronomical names.

How Zohhak fits here? Or is it a roundabout way of saying "just because I liked the sound"?



following http://en.wikipedia.org/wiki/Zahhak it's "a monster with ... three heads"
that name was good because it was rare for google - no need to compete with anything

no clue

Hello Tomek,

unfortunately I can't help you. Zohhak name is a mystery to me as well. I will ask Piotr and if he reveals it, I will put the answer here so all can learn about it.

This used to be my blog. I moved to http://tomek.kaczanowscy.pl long time ago.


Please comment using