SimpleTest module's faults at first sight

Events happening in the community are now at Drupal community events on www.drupal.org.
internal's picture

1. Too heavy to write simple test

if I changed code in blog_link to remove author's blog link, how can I write a small code to ensure it? logic as

testnode = new node;
node->type = blog;
testlink = blog_link('node', testnode);
assertNotContains('tom's blog', testlink);

2. Not IDE friendly, even for simpletest series.

Using simpletest eclipse plugin, you can't run test file because of the .test extention, have to rename to .php. After renaming, it still can be run because of complex file including.

Any thoughts?

Comments

drupal bootstrap and simpletest

cabbiepete's picture

We too had a similar issue where we were trying to run simpletests from the eclipse plugin. I didn't solve it but I did work out that the basic issue was that the simple tests in drupal rely on the drupal bootstrap already being done. This includes a lot of things including the simpletests when you submit the simpletest form on drupal.

To make this runnable outside of that form I think you would need a test runner that did a drupal bootstrap and then ran the tests essentially mimicing what happens on the form submission.

We decided for the time being we could live with running the tests through the drupal site.

Also I haven't tried it but it looks like the drush module http://drupal.org/project/drush has a command line helper for doing exactly this. It might be worth looking at to help with integrating with the eclipse plugin and/or using as a code example for doing that.

a link

Here's some actual

floretan's picture
  1. Here's some actual simpletest code that would do what you want (from what I understand, you want to make sure that users don't see a link to their own blog). It's longer than what you originally had, but by properly structuring your test case a lot of code can be used to test multiple assertions.

<?php
// Create user.
$test_user = $this->drupalCreateUser('create blog content');

// Create a new blog node.
$edit = array(
 
'type' => 'blog',
 
'name' => $test_user->name,
);
$node = $this->drupalCreateNode($edit);

// Test that users don't see their own blog link.
$this->drupalGet('node/' . $node->nid);
$this->assertNoText(t('@name\'s blog', array('@name' => $test_user->name)), t("The author's blog link has been removed"));

// Test that users see other user's blog link.
...
?>

Thank you all. I've tried

internal's picture

Thank you all. I've tried above link and code. It seems they're all for drupal 7 only. I'm using drupal 5. So, It's too advanced for simpletest to use in drupal 5?

Testing and Quality Assurance

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: