Table prefixes with db_select() in SimpleTest tests
Executing queries inside SimpleTest tests is not different from executing them in a module. The path.test file contains the following code, and it is executed without errors.

$forum_vid = db_query("SELECT vid FROM {taxonomy_vocabulary} WHERE module = 'forum'")-&gt;fetchField();
$tid = db_insert('taxonomy_term_data')
  -&gt;fields(array(
    'name' =&gt; $this-&gt;randomName(),
    'vid' =&gt; $forum_vid,
  ))
  -&gt;execute();