Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Test Data Generation
EMF Test Data Generation [message #428180] Thu, 12 March 2009 15:36
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
I am posting this because maybe this is usefull for others also.

I wrote an EMF test data generator. It is currently only available as eclipse project in cvs:
dev.eclipse.org
/cvsroot/modeling
org.eclipse.emf/org.eclipse.emf.texo/plugins/org.eclipse.emf .texo.datagen

The project only has a dependency on EMF.

If there is enough interest I can package it in a plugin.

Some features:
- takes into account containment and bidirectional relations, so EObjects are always created in a containment hierarchy.
- to set ereferences it tries to re-use already created EObjects (of the correct type), to not generate too many objects
- can handle ereferences to abstract types/interfaces (to set such an ereference will randomly select concrete subtypes)
- created eobjects are added to containers if they are present, if there is more than one possible container then it
will select one randomly.
- the test data generator uses data generators for specific eattributes. These eattribute data generators are pretty
simple to implement and add (see the DataGeneratorFactory).
- There are data generators for the numeric types, enum, date and string.
- For String data generators there are some specific implementations for firstname, lastname, city, street, zipcode,
postal code, phone. All of these use a name/word list to generate readable data. So if you have an eattribute with the
name firstname it will use a specific datagenerator which uses readable names. Overall the idea is to extend this with
more name/word list if there is interest.

The main limitation is that the data generator ignores most constraints (if you have defined any like using OCL), this
is a future topic.

Here is some code on how to use the data generator:

ModelDataGenerator dataGenerator = new ModelDataGenerator();
// set the objects which are supposed to be in the top of the containment hierarchy
// in the library example this would be the Library EClass
modelDataGenerator.setStartEClasses(eClasses);
// pass the ePackages
modelDataGenerator.setEPackages(ePackages);
modelDataGenerator.generateTestData();
List<EObject> result = modelDataGenerator.getResult();

There are some parameters to control the depth of the hierarchy and the number of objects created. See the javadoc in
the ModelDataGenerator.

I have tested it with 5 different models and it seemed to work fine with me. It took no effort to create datasets with
10000 or more objects.

Again I hope it is usefull and if so or if not, I am interested in feedback.

--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:EMF Test Data Generation?
Next Topic:collection declarations in OCL expressions
Goto Forum:
  


Current Time: Fri Apr 26 04:25:29 GMT 2024

Powered by FUDForum. Page generated in 0.02871 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top