Posted by internal on June 16, 2008 at 4:31am
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
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
maybe this link can help: http://develoop.be/running_simpletest_drupal_eclipse
Here's some actual
<?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
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?