Wednesday, 12 March 2008

Dummy Content Generator for EPiServer

It's a part of developer's job is to write a code ... it's obvious ... but after that we are also suppose to test the code and make sure that new features actually work. And that's where a test environment including test data is very useful. Creating a few EPiServer pages doesn't take much time so usually it can be done manually... but what if you need 1k or 10k pages? I guess that's a point where you would prefer to generate those pages.

I was facing a problem like that some time ago ... and I decided to wrote Dummy Content Generator!

I know ... it doesn't look very impressive ... but still it is very useful. This small tool made my life simpler :)


How to use Dummy Content Generator
  1. First of all - crate page types which you want to use
  2. Create XML where you define how your dummy data should looks like
  3. Define where dummy data should be added (you can specify parent page ID)
  4. Run it!
Most of the steps is quite simple and self-explanatory, the only one which is worth explaining is creating the XML. Check an example:



As you can see in this example, tag pages contains one page tag which has following attributes:
  • count - defines number of pages which will be generated based on this tag, 1 page in this case,
  • type - page type which will be used,
  • name - name of the page.
and elements:
  • properties - this is a list of properties which you want to set, in this case I don't want to set any properties, this is just an grouping node,
  • children - list of the pages which will be generated under the page.
Now, within children tag there is another page tag, it's worth noticing that this time count attribute is set to 5 which means that 5 pages (article - 0, article -1, article - 2 .... ) will be generated.

And properties ... here we have in general two options:
  1. <property name="Title" randomvalue="true"/>
    It will create property with random value! How? Dummy Content Generator will detect property type and then it will open text file named in the same way as property type to get list of possible values.

    For instance for property of type String it will open file EPiServer.Core.PropertyString.txt, for property of type URL to image it will use EPiServer.SpecializedProperties.PropertyImageUrl.txt and so on ...

    This approach facilitates extending the Generator by custom properties. It's also very simple to change my dummy strings with your own one, maybe more meaningful.

  2. <property name="WriterName" value="Marek Blotny"/>
    Above line will create property with specified value. It will not use random values! No magic here.
And this is final result, six new pages:




How to install Dummy Content Generator on EPiServer 5:

  1. Download zip file
  2. In EPiServer CMS Manager, select the existing EPiServer Web site and then
    Action -> Install Module.
  3. Select DummyContentGenerator.zip to install and that should be all!

Remarks
  • To simplify creating the XML you can download schema from here.
  • VS 2005 project with all sources can be downloaded from here.
  • Sample XML
  • This tool is on a very early stage, it was working for me well, but of course I didn't check all possibilities. It would be great to get some feedback from you, in particular please let me know if you find any bugs!
  • If there will be an interest to improve or add new features to the Generator I'm willing to publish source code on EPiCode and help with improvements.

2 comments:

Per B said...

Great, I also have a content generator but it's not as configurable as yours but it has a Windows app with progress communicating with a web service for long running operations etc. Also has nesting of levels, estimating page count etc. If you're interested, mail me the code and I'll incorporate it in my tool and publish it on EPiCode, I think the two married would be a perfect combo as a base for furhter development. My mail is pb (at) episerver.com.

Steve said...

Maybe this could be part of the Page Mockup Utility already on EPiCode? They sure look the same ( though they solve different purposes. https://www.coderesort.com/p/epicode/wiki/PageMockup/Screenshots)

This is really nice to have when testing performance, design and layout.