2

My goal is to speed up functional tests without tweaking the database. Is it possible to avoid the creation of Simpletests setup tables and use existing tables instead? I read this article where the author states :

Maybe the answer is Simpletest 2 which allows you to run on a "dirty" environment.

So is this "dirty" environement is the answer? If so, how to use it as setup ?

2
  • 1
    I would recommend against doing that. The purpose of a test is to run in a clean, defined environment with explicit configurations. Doing this makes your test result unpredictable. The result depends on manual configuration of the side, so your tests might suddenly fail because required data or configuration is not there, you also can't run your tests if your module isn't enabled. You also can't recover in case your site get's broken because of a wrong test. On decent hardware with proper configuration, it's possible to run a test case in <10s. It's IMHO not worth the hassle of doing this.
    – Berdir
    Commented Jul 9, 2012 at 18:40
  • +1, I just broke my website (dev environment luckiliy) with $this->setup = TRUE;
    – B2F
    Commented Jul 9, 2012 at 22:16

1 Answer 1

1

I have found the answer there. But don't do that !

It's better to move the database on a tmpfs folder (it's > 5x faster), because not only a "dirty" environment does not work, but it will broke your website with a serious error (just happened to me). Hints to tweak the database on this question.

It's there but don't do it :

  // for our functional testing, we want to test the pages and code that
  // we've been generating in the real database. to do this, we need to
  // ignore SimpleTest's normal fake database creation and fake data
  // deletion by overriding it with our own setUp and tearDown. NOTE that
  // if we make our own fake data, we're responsible for cleaning it up!
  function setUp() {
    // support existing database prefixes. if we didn't,
    // the prefix would be set as '', causing failures.
    $this->setup = TRUE; // Drupal 7 way
  }
  function tearDown() { }
0

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.