source: pyenvjasmine/README.rst@ 24:e235afb1bc67

Last change on this file since 24:e235afb1bc67 was 24:e235afb1bc67, checked in by Borja Lopez <borja@…>, 7 years ago

Updated docs and some test files to reflect the change TestRunner/Runner.

Bumped version to 0.1.7

File size: 2.5 KB
RevLine 
[0]1Python envjasmine wrapper
2=========================
3
4This is a thin python wrapper around the envjasmine_ JavaScript
5testing framework.
6
[8]7
8.. contents::
9
10
11Installation
12------------
13
[24]14You can install pyenvjasmine using pip_::
[8]15
16 pip install pyenvjasmine
17
18Or you can grab the latest sources and install it from there::
19
20 python setup.py install
21
22Also, you can use it directly from the sources directory, in *development mode*
23(useful if you want to contribute to the project)::
24
[21]25 pip install -e .
[8]26
27.. note::
28
29 More about the *development mode* here:
30
31 https://packaging.python.org/en/latest/distributing.html#working-in-development-mode
[0]32
33
[11]34Running pyenvjasmine tests
35--------------------------
[0]36
[11]37To run the tests on this code here (as opposed to *your* JavaScript code you
38want to test), install pyenvjasmine and then run::
[0]39
40 nosetests --cover-package=pyenvjasmine --cover-erase \
41 --with-coverage --with-doctest $*
42
[8]43.. note::
44
45 If you have installed pyenvjasmine in *development mode*, you can simply
46 run::
47
[11]48 nosetests -c nose.cfg
[8]49
[11]50 to run the tests from within the pyenvjasmine sources directory.
[8]51
[0]52
53Run your own tests
54------------------
55
[11]56The easiest way is to put your "specs" (JavaScript tests) into some directory
57in your code, then in your python tests, add a new TestCase with just one test
58that runs all your JavaScript tests.
[0]59
[11]60The simplest solution is to set capture_output to False, so you see the output
61from the js tests on the console. Something like this::
[0]62
63 import unittest
[24]64 from pyenvjasmine.runner import Runner
[0]65
66 class JavaScriptTests(unittest.TestCase):
67 def test_my_javascript(self):
[24]68 runner = Runner(
69 testdir='/path/to/my/testdir',
70 configfile='relative/path/to/configfile')
[0]71 runner.run(capture_output=False)
72
73
[11]74If you want a more integrated test control, you could set capture_output to
75True, then parse the test output that is returned from the run() method, with
76something like this::
[0]77
[11]78 import unittest
[24]79 from pyenvjasmine.runner import Runner
[11]80
81 class JavaScriptTests(unittest.TestCase):
[0]82 def test_my_javascript_no_output(self):
[24]83 runner = Runner(
84 testdir='/path/to/my/testdir',
85 configfile='relative/path/to/configfile')
[0]86 res = runner.run(capture_output=True)
87 lines = res.splitlines()
88 self.assertTrue('Failed: 0' in lines)
89
[8]90
91.. _envjasmine : https://github.com/trevmex/EnvJasmine
92.. _pip: http://www.pip-installer.org/en/latest/index.html
93.. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall
Note: See TracBrowser for help on using the repository browser.