Reputation: 1175
Is there any tool like nBuilder for java?
I want to build objects for unit testing and I dont want to have one builder class for each entity in my domain.
I am currently using mockito but it doesnt replace the functionality of nBuilder.
Upvotes: 11
Views: 1057
Reputation: 6096
I'm not familiar with nBuilder, but it looks to have some overlap with QuickBuilder - a project I put together that generates on the fly implementations of test data builders to interfaces you supply.
https://github.com/hcoles/QuickBuilder
It has some support for producing sequences of values, but does not generate values for you as nBuilder seems to.
Also, similar in functionality to QuickBuilder but presenting a different interface is, makeiteasy
https://code.google.com/p/make-it-easy/
Upvotes: 1
Reputation: 810
While not strictly matching what you want with nBuilder, I'd strongly recommend looking into the Spock testing framework. It has very strong mocking and stubbing tools built into it, and one of the greatest perks of Spock is Data Driven testing.
http://docs.spockframework.org/en/latest/data_driven_testing.html
I find data driven testing to be some of the most efficient unit testing I've come across, to date. I don't know if this will directly replace the kinds of things nBuilder can do, but I can tell you that my unit testing is much more thorough (and easier to write) with Spock.
Upvotes: 2
Reputation: 1569
You can try DataFactory: Generate test data with DataFactory
Also I found this poject at google code that could be helpful: Random Data Generator
They are not equivalent to nBuilder, but they try to provide similar functionality to the one provided by nBuilder. It's not a perfect replacement but is the closer I could find.
Hope this helps.
Upvotes: 4