0

I have a custom module that's fairly mature and I'm just now getting around to writing tests for it. However, I'm having difficulty getting the it to show up in the tests menu. What is the bare minimum that I need to get automated testing going for my module?

I have:

module.info:

files[] = tests/module.test

tests/module.test:

<?php
class ModuleTestCase extends DrupalWebTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Module Test',
      'description' => 'Automated testing of Module.',
      'group' => 'Module',
    );
    function testModule() {
      $this->assertTrue(TRUE, 'Tests are working');
    }
  }
}

I've even set up a bogus test module that's basically what's outlined above, and it works. But my module with all my functionality it in won't show its tests on the test menu. So I'm trying to see if there's anything simple I'm overlooking.

Does the test file have to be called module.test or can it be called anything.test? Does the name of the class have to be ModuleTestCase or can it be arbitrary? I do have my files called module.test and the class called ModuleTestCase. I've also run the module.test on the command line php to test for syntax errors and I get none. What could I be overlooking?

2

What you got there will suffice. I copied the code to a project I was working on and it showed up fine.

You problem is either:

  • Cache (You need to clear cache after updating the .info file)
  • Overlooked, The test could be there, but you didn't see it. It will show up under the group with the name written in name.
1
  • Overlooked is the right answer. I had "comments" in my module.info file that began with #. Apparently parsing stops on those lines without any error notice. The test files were declared afterwards :Þ – user1359 Jul 26 '11 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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