When I am writing unit tests in dynamically-typed Ruby or Python, I use the libraries factory_girl and factory_boy, respectively, in order to conveniently generate objects under test. They provide convenient features over direct object instantiation, for example:
- factory inheritance and overrides
- field defaults and overrides
- lazily-computed dependent/derived fields
- construction of dependent/related other objects
- implicit lazy field dependency resolution
What are some libraries/frameworks I could use while writing unit tests in statically-typed Java or Scala to achieve similar effects with similar benefits?
Thanks in advance!
I found a similar StackOverflow question from the past here, but unfortunately, the top answer is (paraphrased), "there is no direct equivalent because that would be pointless".