Skip to content

Commit

Permalink
add sniffer
Browse files Browse the repository at this point in the history
  • Loading branch information
proteusvacuum committed May 12, 2015
1 parent 913bc16 commit c8d2695
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,24 @@ The tests for CloudCare currently expect the "Basic Tests" app from the
Make sure to edit the selenium user credentials in `localsettings.py`. Then run

./manage.py seltest

## Sniffer

You can also use sniffer to auto run the python tests.

When running, sniffer auto-runs the specified tests whenever you save a file
For example, you are working on the `retire` method of `CommCareUser`. You are writing a `RetireUserTestCase`, which you want to run every time you make a small change to the `retire` method, or to the `testCase`. Sniffer to the rescue!

### Sniffer Usage

```sh
sniffer -x <app_name>[.<TestClass>[.<test_name>]]
```
In our example, we would run `sniffer -x users.RetireUserTestCase`
You should see beautiful green `In good standing` if all is well, otherwise a `Failed - Back to work!` message is displayed.
If you want to run the whole test suite whenever a file is changed (not recommended), you would run sniffer without the `-x` argument
### Sniffer Installation instructions
https://github.com/jeffh/sniffer/
(recommended to install pyinotify or macfsevents for this to actually be worthwhile otherwise it takes a long time to see the change)
1 change: 1 addition & 0 deletions requirements/dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Jinja2==2.7.1
docutils==0.11
-e git+git://github.com/dimagi/[email protected]#egg=luna
fixture
sniffer
9 changes: 9 additions & 0 deletions scent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from subprocess import call
from sniffer.api import runnable


@runnable
def execute_tests(*args):
fn = ['python', 'manage.py', 'test', '--noinput']
fn += args[1:]
return call(fn) == 0

0 comments on commit c8d2695

Please sign in to comment.