I'm trying to learn how to do testing in Drupal. I'm pretty new with it so maybe i didn't got it right. well, I'm trying to test some views of content types, but to test those views i need to have that content type created when im testing. actually with drupalWebTestCase it's seems it doesn't load the content types that i would have in my normal drupal(except for the basics).

I tried to use simpletest clone but it doesn't work,don't know why, and I don't need all the database for it, just the content types and views.

So... Is there a way to load that content type WITHOUT having to create everything by code? I've a lot of content types some with some complicated fields and loading one by one sounds too harsh to be done.

2 Answers 2


Export your content types and fields using Features. Features creates modules which you can then enable in your Simpletest setUp step.

When you create a feature you are offered the opportunity to add components to it including content types. Features tries to detect related components such as fields that you will require. When your feature is complete you then download it and add it to your project like any other module.

You may need to add on extra Features-related modules such as Strongarm, to help further with initializing your test environment.


Try the SimpleTest Clone module.

SimpleTest performs the test on a clean Drupal installation, so if you have created Content Types they will not be available.

SimpleTest Clone craetes a copy of the database (using a table prefix) and performs the tests over those tables, so all config you have done is present.

Once the tests are donde the extra tables are deleted.

The drawback fo this method is that is a little slower than standard SimpleTest because the table copy operation.

To use SimpleTest Clone just subclass your test class form SimpleTestCloneTestCase class instead of DrupalWebTestCase class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.