All Projects → SublimeText → Unittesting

SublimeText / Unittesting

Licence: mit
Testing Sublime Text Packages

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Unittesting

unitest
🌎 Seamless node and browser unit testing with code coverage
Stars: ✭ 28 (-70.53%)
Mutual labels:  coverage-report, unittest
Covr
Test coverage reports for R
Stars: ✭ 285 (+200%)
Mutual labels:  travis-ci, coverage-report
cpp14-project-template
A simple, cross-platform, and continuously integrated C++14 project template
Stars: ✭ 64 (-32.63%)
Mutual labels:  travis-ci, appveyor
Chromecast
Chromecast desktop app: Node.js, Electron, React & Material-UI.
Stars: ✭ 49 (-48.42%)
Mutual labels:  travis-ci, appveyor
Cargo Make
Rust task runner and build tool.
Stars: ✭ 895 (+842.11%)
Mutual labels:  appveyor, travis-ci
CPP Template
C++ project template : CMake, Test, Travis CI, Appveyor, CodeCoverage, Doxygen
Stars: ✭ 32 (-66.32%)
Mutual labels:  travis-ci, appveyor
Skyhook
Parses webhooks and forwards them in the proper format to Discord.
Stars: ✭ 263 (+176.84%)
Mutual labels:  appveyor, travis-ci
continuous-integration-with-python
How to test your python code. How to automatically run your tests for your Python code. How to get reports of the tests coverage
Stars: ✭ 25 (-73.68%)
Mutual labels:  travis-ci, coverage-report
Polly
🔧 Collection of CMake toolchain files and scripts for cross-platform build and CI testing (GCC, Visual Studio, iOS, Android, Clang analyzer, sanitizers etc.)
Stars: ✭ 778 (+718.95%)
Mutual labels:  appveyor, travis-ci
Cibuildwheel
🎡 Build Python wheels for all the platforms on CI with minimal configuration.
Stars: ✭ 620 (+552.63%)
Mutual labels:  appveyor, travis-ci
spring-discord-bot
Discord all-purpose bot, made using Spring Boot, JPA, Hibernate, REST, HikariCP. Written for fun, do not take this serious.
Stars: ✭ 26 (-72.63%)
Mutual labels:  travis-ci, appveyor
Phpspec Code Coverage
Generate Code Coverage reports for PhpSpec tests
Stars: ✭ 59 (-37.89%)
Mutual labels:  unittest, coverage-report
react-testing-mocha-chai-enzyme
A solid test setup for React components with Mocha, Chai, Sinon, Enzyme in a Webpack/Babel application.
Stars: ✭ 48 (-49.47%)
Mutual labels:  travis-ci, coverage-report
ci playground
Playground for Cloud CI development for C++
Stars: ✭ 23 (-75.79%)
Mutual labels:  travis-ci, appveyor
ci-skip
CI skip comment
Stars: ✭ 35 (-63.16%)
Mutual labels:  travis-ci, appveyor
CI-Utils
Utilities for running Common Lisp on CI platforms
Stars: ✭ 18 (-81.05%)
Mutual labels:  travis-ci, appveyor
HaxeCI
An example of using CI for Haxe projects.
Stars: ✭ 45 (-52.63%)
Mutual labels:  travis-ci, appveyor
cibuildwheel
🎡 Build Python wheels for all the platforms on CI with minimal configuration.
Stars: ✭ 1,350 (+1321.05%)
Mutual labels:  travis-ci, appveyor
Ci helloworld
A simple example of how to setup a complete CI environment for C and C++
Stars: ✭ 357 (+275.79%)
Mutual labels:  appveyor, travis-ci
Bors Ng
👁 A merge bot for GitHub Pull Requests
Stars: ✭ 878 (+824.21%)
Mutual labels:  appveyor, travis-ci

UnitTesting

Github Action CircleCI Build Status Build status codecov

This is a unittest framework for Sublime Text. It runs unittest testcases on local machines and CI services such as Travis CI, Circle CI and AppVeyor. It also supports testing syntax_test files for the new sublime-syntax format.

Sublime Text 4

Sublime Text 4 is now supported (with some caveats)

  • Running coverage on Python 3.8 packages is not working now.
  • Only local testing is supported now (CI services are not working).

Preparation

  1. Before testing anything, you have to install UnitTesting via Package Control.
  2. Your package!
  3. TestCases should be placed in test*.py under the directory tests (configurable, see below). The testcases are then loaded by TestLoader.discover.

Here are some small examples

Running Tests Locally

UnitTesting can be triggered via the command palette command UnitTesting. Enter the package name in the input panel and hit enter, a console should pop up and the tests should be running. To run only tests in particular files, enter <Package name>:<filename>. <filename> should be a unix shell wildcard to match the file names, <Package name>:test*.py is used in default.

You could run the command UnitTesting: Test Current Package to run the current package. The current package will be first reloaded by UnitTesting and then the tests will be executed.

It is also possible to generate test coverage report via coverage by using the command UnitTesting: Test Current Package with Coverage. The file .coveragerc is used to control the coverage configurations. If it is missing, UnitTesting will ignore the tests directory.

Continuous Integration

These environmental variables are used in the CIs.

  • PACKAGE: the package name, it is needed if the repo name is different from the package name.
  • SUBLIME_TEXT_VERSION: 2 or 3
  • SUBLIME_TEXT_ARCH: x32 or x64
  • UNITTESTING_TAG: a specific version of UnitTesting to use

Following CI's are supported.

Linux macOS Windows
GitHub Actions
CircleCI
Travis CI
AppVeyor

GitHub Actions

To enable GitHub Actions, copy the file build.yml to your repository.

Circle CI

To enable Circle CI builds, copy the file .circleci/config.yml to your repository. Log in to Circle CI and add a new project.

Circle CI doesn't offer free macOS plan at the moment, but you could contact them for access if your package is open sourced:

We also offer the Seed plan for macOS open-source projects. Contact us at [email protected] for access. If you are building a bigger open-source project and need more resources, let us know how we can help you!

Travis CI

To enable Travis CI Linux and macOS builds, copy the file: .travis.yml (caution: with a beginning dot) to your repository. Log in to Travis CI to enable CI for your package..

AppVeyor CI

To enable AppVeyor Windows builds, copy the file appveyor.yml to your repository. Log in to AppVeyor and add your repository as a new project.

Coverage reports

We support Codecov, Coveralls and Codacy. Codecov is recommended as it supports merging reports from different CIs.

Codecov

To submit coverage report to codecov.io:

  1. install codecov
  2. run codecov after success

For GitHub Actions, copy the CODECOV_TOKEN from codecov.io to GitHub's Secret tab.

Coveralls

To submit coverage report to coveralls.io:

  1. install python-coveralls
  2. run coveralls after success

Codacy

To submit coverage report to codacy.com:

  1. install both coverage and codacy-coverage

    pip install coverage codacy-coverage
    
  2. generate the xml report: coverage xml -o coverage.xml

  3. run python-codacy-coverage

Installing Package Control and Dependencies

If your package uses Package Control dependencies, you may want to install Package Control by uncommenting the line of install_package_control in Travis CI and AppVeyor configuration files.

Testing syntax_test files

Check this for an example.

Options

Use a different test directory

The default test directory is "tests". To change the test directory, add a file unittesting.json to your repo with the corresponding directory name, eg unittest:

    "tests_dir" : "unittest"

Redirect test result to a file

The test result could be redirected to a file by specifying the output variable in unittesting.json.

    "output" : "foo.txt"

Deferred testing

Tests can be written using the Deferrable testcase, such that you are able to run sublime commands from your test cases and yield control to sublime text runtime and continue the execution later. Would be useful to test asynchronous codes.

An example would be found in here.

To activate deferred testing, put the following line in unittesting.json.

    "deferred": true,

PS: this idea was inspired by Plugin UnitTest Harness.

DeferrableTestCase is used to write the test cases. They are executed by the DeferringTextTestRunner and the runner expects not only regular test functions, but also generators. If the test function is a generator, it does the following

  • if the yielded object is a callable, the runner will evaluate the callable and check its returned value. If the result is True, the runner continues the generator, if not, the runner will wait until the condition is met.

  • If the yielded object is an integer, say x, then it will continue the generator after x ms.

  • Otherwise, the yield statement would yeild to any queued jobs.

Async testing

By default, the tests are running in the main thread and can block the graphic inference. Asychronized testing could be used if you need the interface to respond.

Async tests are usually slower than the sync tests because the interface takes time to respond but it is useful when there are blocking codes in the tests. An example would be found in here.

However, it is known that async test does not work very well with coverage. In general, it is recommended to use deferred testing over async testing since there is no need to worry about race condition.

To activate async testing on Travis CI and AppVeyor, put the following line in unittesting.json.

    "async": true,

Note: if async is true, deferred is forced to be false (relaxation of this is in progress)

Others

Add Test Current Package build

It is recommended to add the following in your .sublime-project file so that c+b would invoke the testing action.

"build_systems":
[
  {
    "name": "Test Current Package",
    "target": "unit_testing_current_package",
  }
]

Docker container

Check https://github.com/SublimeText/UnitTesting/tree/master/docker

Credits

Thanks guillermooo and philippotto for their efforts in AppVeyor and Travis CI macOS support.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].