Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Test framework for Sublime Text 3 packages
Python PowerShell
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
lib
tests
.hgignore
AAAPT.sublime-project
CHANGES.txt
Default.sublime-commands
LICENSE.txt
README.md
manifest.json
runner.py
test_harness.py
utils.py

README.md

AAAPT

Package Tests - a test framework for Sublime Text packages.

Installation

  1. Download the latest build
  2. Copy AAAPT.sublime-package to Packages/Installed Packages
  3. Restart Sublime Text.

To locate Packages/Installed Packages, you can open the console (Ctrl+`) and run this:

sublime.installed_packages_path()

How to Use

AAAPT lets you run tests in the context of Sublime Text. To use AAAPT correctly you need to ensure two things:

  • Your package has specified tests to be run by AAAPT
  • There's no other currently loaded .sublime-package that includes AAPT tests

Specifying tests is easy. Simply create a file like test_harness.py at the top level of your FooPackage.sublime-package and include something like this:

from AAAPT.runner import register_tests

test_suites = {
    'baz': ['FooPackage.tests.test_baz'],
}

register_tests(test_suites)

Now you can write the still inexistent tests. First we create a file to hold them:

cd path/to/FooPackage
touch tests/test_baz.py

Then we write the tests:

import unittest

from AAAPT.utils import BufferTest


# Test that uses AAAPT's helpers.
class Test_BufferSample(BufferTest):
    def testSample(self):
        self.set_text('foo bar\nfizz buzz\n')
        self.add_sel(self.R((1, 0), (1, 4)))    
        self.assertEqual(self.view.substr(self.first_sel()), 'fuzz')


# Regular test.
class Test_Sample(unittest.TestCase):
    def testSample(self):
        self.assertTrue(False)

Finally, we can publish FooPackage.sublime-package to Installed Packages, restart Sublime Text and, from the Command Palette, select Run Active Tests.... The results of the test run will be printed to a new view.

Donate

If you like this package and want to thank me, you can do so here:

Paypal Gittip Pledgie

Something went wrong with that request. Please try again.