Todd Wolfson

Software Engineer

December 26, 2013

Introducing the first Sublime Text plugin testing framework. Now you can rest easy and iterate faster with cross-version tests that integrate with Vagrant and Travis CI.

# Load in test framework
from sublime_plugin_tests import framework

# Define a TestCase
class TestLeftDelete(framework.TestCase):
    def test_left_delete_single(self):
        # Each test function *must* return Python with
        # a `run` function. `run` will be run inside
        # Sublime Text. Perform your assertions etc there.
        return """
# Use ScratchView utility provided by `sublime_plugin_tests`
from utils.scratch_view import ScratchView

def run():
  # Generate new scratch file
  scratch_view = ScratchView()
      # Update the content and selection `ab|c`
      scratch_view.set_sel([(2, 2)])

      # Delete one character to the left `a|c

      # Assert the current content
      assert scratch_view.get_content() == 'ac'
      # No matter what happens, close the view
$ # Run tests via nosetests
$ nosetests
Ran 1 test in 0.076s


Top articles

Lessons of a startup engineer

Lessons from being a 3x first engineer, former Uber engineer, and working at even more startups

Develop faster

Removing the tedium from creating, developing, and publishing repos.

Sexy bash prompt

A bash prompt with colors, git statuses, and git branches.