Testopia is a selection/cursor position based 'python unittest' launcher for 'Sublime Text 4'. It is designed to directly run python unittest from your 'Sublime Text' developing group using a single key press Ctrl+b.
NOTE: This tool is in alpha. Quick start: https://www.youtube.com/watch?v=hmEVR6SLkt0
While working on your class method within your python module.py file, syncronously work on your tests within your test/test_module.py file.
Then, to test:
- place your cursor in any position inside a method (OTHER than the beginning of a line) and press Ctrl+b to run the test for that individual class/method
- place your cursor at the begining of a line and press Ctrl+b to test the entire module
- place your cursor in multiple classes/methods and press Ctrl+b to test those classes/methods simultaneously
- select a region of your code and press Ctrl+b to test only classes/methods within that region
Testopia assumes and facilitates a TDD (test driven) or TSD (test syncronous) continuous delivery approcach. It requires you to adhere to the folowing principles:
- Object oriented programming (classes, methods) in your /package/module.py file
- Object oriented Unitest(unittest.TestCase) setup using a /test/test_module.py file
Also Testopia is currently limited to some technical choices you make.
- Sublime Text 4 (test results will be displayed within the Sublime Console)
- Pipienv environments
Before install check your Sublime and Project specification! (see Environment header below!)
NOTE: This tool is in alpha, so do expect some bugs to show up!
- Sublime Text 4
- currently only Pipenv environments are supported
- requires a biased development setup with a test foder within your project directory
- clone this repo into your Sublime Text 4 packages or download the zip file and unpack it into the package folder
- this results in a directory like: ~/AppData/Roaming/Sublime Text/Packages/testopia
- copy the testopia.sublime-build file into /Packages/User folder and adjust it to your needs
- make sure all variant parameters within the testopia.sublime-build file are set to your project specifications
- select testopia as a build system for your project (Tools->Build System->testopia)
cd "~\AppData\Roaming\Sublime Text\Packages"
git clone git@github.com:lmielke/testopia.git
mv .\testopia\testopia.sublime-build ./User
# in 'Sublime Text' select: Tools >> Build System >> testopia
Testopia will create a test/testopia_logs/log... folder within your test folder. This log folder will contain all test logs and will be updated with each test run. A new log file will be created each time you run the test Ctrl+b.
You can limit the life time of your logfiles by adjusting the logPreserveThreshold within your testopia.sublime-build file. The default is set to 10, meaning that by default only the last 10 log files will be preserved. Currently there is no Reporting implemented in Testopia. This is a feature that might be added in the future.
- in some cases the logfile from a previous test might not have been properly closed. In that case, save your work. Then close and reopen 'Sublime Text'. This will release the lock. You can also increase the threshold for log preservation within the testopia.sublime-build file so it will not be deleted during the current session.