Answers.Body: <p>If you have installed <a href="https://github.com/civicrm/civicrm-buildkit">civicrm-buildkit</a> and configured <a href="https://github.com/civicrm/civicrm-buildkit/blob/master/doc/civibuild.md">civibuild</a>, then you can use the tutorial steps at <a href="https://github.com/civicrm/civicrm-buildkit/blob/master/doc/daily-coding.md#upgrade-tests">Daily Coding: Upgrade Tests</a>.</p>
  
  <p>If you don't use civibuild, then you can piece-together a similar workflow using <a href="https://github.com/civicrm/civicrm-upgrade-test/">civicrm-upgrade-test</a>.</p>
  
  <p>For more discussion about writing upgrade logic, see <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Upgrade+Reference">Upgrade Reference</a> on the wiki.</p>
  
  <p>For a general, high-level overview of automated tests (including upgrade tests), see <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Testing">Testing</a> on the wiki.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-04T09:40:13.443Z
Answers.LastActivityDate: 2015-04-04T09:51:39.600Z
Answers.LastEditDate: 2015-04-04T09:51:39.600Z
Answers.UserDisplayName: Tim Otten
Body: <p>I have a PR that adds a file CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl.  How should I go about testing this code?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-07T02:09:27.050Z
Comments.Text: Note that the more common case is to be inserting upgarde code into a file like this. In both cases the important thing is to test the upgrade code works properly. JMA has found that it is useful to test db upgrade code against a variety of dbs that have been found in the wild, as well as the tests that automatically check upgrades on the default db.
Comments.UserDisplayName: Joe Murray
Tags: <sql><developer><upgrade>
Title: How do I test a CiviCRM upgrade script?
ThreadText: # How do I test a CiviCRM upgrade script?
  
  (Asked by: username_0 on 2015-04-04)
  
  I have a PR that adds a file CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl. How should I go about testing this code?
  
  **Tags:** sql, developer, upgrade
  
  > **Comments:**
  > **username_1**: Note that the more common case is to be inserting upgarde code into a file like this. In both cases the important thing is to test the upgrade code works properly. JMA has found that it is useful to test db upgrade code against a variety of dbs that have been found in the wild, as well as the tests that automatically check upgrades on the default db.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-04-04. Score: 10 | Accepted answer
  
  If you have installed [civicrm-buildkit](https://github.com/civicrm/civicrm-buildkit) and configured [civibuild](https://github.com/civicrm/civicrm-buildkit/blob/master/doc/civibuild.md), then you can use the tutorial steps at [Daily Coding: Upgrade Tests](https://github.com/civicrm/civicrm-buildkit/blob/master/doc/daily-coding.md#upgrade-tests).
  
  If you don't use civibuild, then you can piece-together a similar workflow using [civicrm-upgrade-test](https://github.com/civicrm/civicrm-upgrade-test/).
  
  For more discussion about writing upgrade logic, see [Upgrade Reference](http://wiki.civicrm.org/confluence/display/CRMDOC/Upgrade+Reference) on the wiki.
  
  For a general, high-level overview of automated tests (including upgrade tests), see [Testing](http://wiki.civicrm.org/confluence/display/CRMDOC/Testing) on the wiki.
  
  
  ---
  
  