DSL to generate test data

Posted by queen3 on Stack Overflow See other posts from Stack Overflow or by queen3
Published on 2010-04-13T11:54:18Z Indexed on 2010/04/13 12:13 UTC
Read the original article Hit count: 295

Filed under:
|
|

There're several ways to generate data for tests (not only unit tests), for example, Object Mother, builders, etc. Another useful approach is to write test data as plain text:

product: Main; prices: 145, 255; Expire: 10-Apr-2011; qty: 2; includes: Sub
product: Sub; prices: 145, 255; Expire: 10-Apr-2011; qty: 2

and then parse it into C# objects. This is easy to use in unit tests (because deep inner collections can be written in single line), this is even more convenient to use in FitNesse-like system (because this DSL naturally fits into wiki), and so on.

So I use this and write parser, but it's tedious to write each time. I'm not a big expert in DSL/language parsers, but I think they can help here. What would be the right one to use? I only heard about:

  • DSL (I mean, any DSL)
  • Boo (that I think can do DSL)
  • ANTLR

but I don't even know which one to pick and where to start.

So the question: is it reasonable to use some kind of DSL to generate test data? What would you suggest to do so? Are there any existing cases?

© Stack Overflow or respective owner

Related posts about unit-testing

Related posts about dsl