Sublime Forum

Automated Testing of Plugins

#1

Hi, All. Anyone tried writing automated tests for sublime plugins?

I’ve never done unit testing in python, and so I’m not sure quite how to go about it. What I’d like to do is something like this;

  1. be able to develop the files as normal, dropping python into package folders.
  2. also embed tests, which only run when you press ‘F7’

I assume I’m going to need some mock objects representing Sublime views, windows, etc. Anyone tried anything like this, and have some pointers?

0 Likes

#2

I haven’t tried it, but I expect you could create some modules called sublime and sublimeplugin with the mock objects, and place them in the system python path, such that they’d be available to stand alone python (i.e., when run via F7), but wouldn’t be visible when loaded via Sublime Text.

Python’s unit testing library (docs.python.org/lib/minimal-example.html) is pretty easy to work with.

0 Likes