-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
README.testing
111 lines (75 loc) · 3.19 KB
/
README.testing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
The short story
===============
Python-based tests:
"build/env/bin/desktop test all" runs all the tests.
You should be running that before you push.
Windmill-tests:
build/env/bin/desktop test windmill
runs all the windmill tests. It uses port 8999.
build/env/bin/desktop runserver_plus
followed by
build/env/bin/windmill -e test=core/src/desktop/windmilltests.py firefox http://localhost:8000/
Longer story
============
The ``test`` management command prepares the arguments (test app names)
and passes them to nose (django_nose.nose_runner). Nose will then magically
find all the tests to run.
Tests themselves should be named *_test.py. These will be found
as long as they're in packages covered by django. You can use the
unittest frameworks, or you can just name your method with
the word "test" at a word boundary, and nose will find it.
See apps/hello/src/hello/hello_test.py for an example.
Helpful command-line tricks
===========================
To run tests that do no depend on Hadoop, use:
build/env/bin/desktop test fast
To run all tests, use:
build/env/bin/desktop test all
To run only tests of a particular app, use:
build/env/bin/desktop test specific <app>
E.g.
build/env/bin/desktop test specific filebrowser
To run a specific test, use:
build/env/bin/desktop test specific <test_func>
E.g.
build/env/bin/desktop test specific useradmin.tests:test_user_admin
Start up pdb on test failures:
build/env/bin/desktop test <args> --pdb --pdb-failure
Special environment variables
=============================
DESKTOP_LOG_LEVEL=<level>
level can be DEBUG, INFO, WARN, ERROR, or CRITICAL
When specified, the console logger is set to the given log level. A console
logger is created if one is not defined.
DESKTOP_DEBUG
A shorthand for DESKTOP_LOG_LEVEL=DEBUG
DESKTOP_PROFILE
Turn on Python profiling. The profile data is saved in a file. See the
console output for the location of the file.
DESKTOP_LOG_DIR=<dir>
Specify the desktop log directory. Defaults to ./log.
DESKTOP_DEPENDER_DEBUG
When specified, re-evaluate the js depender every time.
DESKTOP_DB_CONFIG=<db engine:db name:test db name:username:password:host:port>
Specify alternate DB connection parameters for desktop to use. Useful for
testing your changes against, for example, MySQL instead of sqlite. String
is a colon-delimited list.
Writing tests that depend on Hadoop
===================================
Use mini_cluster.py! You should tag such tests with "requires_hadoop", as follows:
from nose.plugins.attrib import attr
@attr('requires_hadoop')
def your_test():
...
Hudson Configuration
====================
Because building Hadoop (for the tests that require it) is slow, we've
separated the Hudson builds into "fast" and "slow". Both are run
via scripts/hudson.sh, which should be kept updated with the latest
and greatest in build technologies.
Headless Windmill
=================
Ideally, all you need to do is install xvfb and run "xvfb-run bin/desktop test_windmill".
To debug, however, you'll need to be able to check out what's going on. You can run
"xvfb-run bash", followed by "x11vnc", and then connect to your X via VNC from another
machine. This lets you eavesdrop nicely.