In a test class, I have:

  public function setUp() {
    DrupalWebTestCase::setUp('search', 'search_by_page', 'sbp_attach', 'content', 'filefield', 'search_files', 'sbp_test', 'dblog');

The "content" (CCK) module is missing from this particular Drupal installation, as well as 'filefield'.

So this line, in my opinion, should cause a test failure (and hopefully an abort of the rest of the test) on that setup line with a message like "All required modules found".

But instead, the test continues all green/passed until farther down when some action actually tries to call a function that is in the content module, and then the entire set of tests I was running abort with a PHP error.

CommentFileSizeAuthor
#9 testfail.png12.92 KBjhodgdon

Comments

jhodgdon’s picture

Title: Missing module does not cause test failur in setup » Missing module does not cause test failure in setup
dave reid’s picture

Status: Active » Fixed

You should be using the 'dependencies' in the getInfo() so the test won't even run if the module isn't found. For example:

class YourTestCase extends XMLSitemapTestHelper {
  public static function getInfo() {
    return array(
      'name' => 'My module test case',
      'description' => 'Description goes here.',
      'group' => 'Search by page',
      'dependencies' => array('content', 'filefield', 'search_files'),
    );
  }

  ....
}
jhodgdon’s picture

Ah, my mistake! Thanks for clearing that up. Must have missed that in the doc...

jhodgdon’s picture

Title: Missing module does not cause test failure in setup » Module depdencies needs how-to doc for SimpleTest
Component: Code » Documentation
Status: Fixed » Active

Actually, I don't see that in the doc... I can add it (or someone else can), but for the moment I will change the component/status/title.

It seems like it should be mentioned on probably all of these pages:
http://drupal.org/node/395012
http://drupal.org/node/30010
http://drupal.org/node/325974

jhodgdon’s picture

Title: Module depdencies needs how-to doc for SimpleTest » Module dependencies needs how-to doc for SimpleTest

I apparently cannot spell today

jhodgdon’s picture

Ummm... Does this dependency check work in 6.x?

I did this:

  public static function getInfo() {
    return array(
      'name' => t('Search by Page Attach CCK Test 2'),
      'description' => t('Test functionality of sbp_attach.module with CCK FileField module. Note that this test assumes you have uploaded the Search Files API, CCK, and FileFields modules, and it also assumes that the default configuration of the Search Files API module "text helper" will work.'),
      'group' => t('Search by Page'),
      'dependencies' => array('search', 'sbp_test', 'sbp_attach', 'content', 'filefield', 'search_files', 'dblog', 'search_by_page'),
    );
  }

  public function setUp() {
    DrupalWebTestCase::setUp('search', 'search_by_page', 'sbp_attach', 'content', 'filefield', 'search_files', 'sbp_test', 'dblog');
 

Then I removed the CCK module from this installation on my test box.

But the test was allowed to run, and only failed when it tried to call a function in the CCK module.

dave reid’s picture

Category: bug » task

Oh yes, I thought this was documented at some point, so thanks for pointing that out!

dave reid’s picture

@jhodgdon Make sure your test file cache is cleared by using the 'Clean environment' button on the SimpleTest page.

jhodgdon’s picture

StatusFileSize
new12.92 KB

Hmmm...

I'm running SimpleTest 6.x-2.10 on Drupal 6.15.

I removed the cck directory from sites/all/modules, cleared all caches on the Performance tab, went to Modules list and refreshed (to verify Content is not listed in the CCK section of the modules list), went to Testing and clicked the "Clean environment" button a few times (until it came back clean).

Then tried to run my test, whose header is:

 public static function getInfo() {
    return array(
      'name' => t('Search by Page Attach CCK Test 1'),
      'description' => t('Test functionality of sbp_attach.module with CCK FileField module. Note that this test assumes you have uploaded the Search Files API, CCK, and FileFields modules, and it also assumes that the default configuration of the Search Files API module "text helper" will work.'),
      'group' => t('Search by Page'),
      'dependencies' => array('search', 'sbp_test', 'sbp_attach', 'content', 'filefield', 'search_files', 'dblog', 'search_by_page'),
    );
  }

  public function setUp() {
    DrupalWebTestCase::setUp('search', 'search_by_page', 'sbp_attach', 'content', 'filefield', 'search_files', 'sbp_test', 'dblog');

I got an error screen, and then when I clicked "go to the error page" I got the attached screen showing the error. The error is in filefield.install. From what you are saying, it looks like it should have errored out sooner or refused to run?

dave reid’s picture

Oh, 6.x-2.x SimpleTest is missing the dependency checking for test files. Needs to be backported from #343502: Allow tests to require and test existance of contrib modules.

jhodgdon’s picture

Title: Module dependencies needs how-to doc for SimpleTest » Module dependencies not being checked in SimpleTest 6.x (and needs doc)
Component: Documentation » Code
Category: task » bug

OK then. I'll set this back to a bug in the code then.

boombatower’s picture

Status: Active » Closed (duplicate)

Should be fixed as requirement for #890440: Backport latest SimpleTest code from D7.

kenorb’s picture