How do I test a CiviCRM upgrade script?
If you have installed civicrm-buildkit and configured civibuild, then you can use the tutorial steps at Daily Coding: Upgrade Tests.

If you don't use civibuild, then you can piece-together a similar workflow using civicrm-upgrade-test.

For more discussion about writing upgrade logic, see Upgrade Reference on the wiki.

For a general, high-level overview of automated tests (including upgrade tests), see Testing on the wiki.