Dummy data and unit testing strategies in a modular application stack

前端 未结 3 1889

How do you manage dummy data used for tests? Keep them with their respective entities? In a separate test project? Load them with a Serializer from external resources? Or just r

3条回答
  •  醉酒成梦
    2021-02-04 12:24

    This may or may not apply - I'm curious to see an example of your dummy objects and the setup code related. (To get a better idea of whether it applies to your situation.) But what I've done in the past is not even introduce this kind of code into the tests at all. As you describe, it's hard to produce, debug, and especially package and maintain.

    What I've usaully done (and AFAIKT in Java this is the best practice) is try to use the Test Data Builder pattern, as described by Nat Pryce in his Test Data Builders post.

    If you think this is somewhat relevant, check these out:

    • Does a framework like Factory Girl exist for Java?
    • make-it-easy, Nat's framework that implements this pattern.

提交回复
热议问题