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.
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.
TestNG has @DataProvider and @Factory.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With