doc/book/en/tutorials/tools/windmill.rst
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 24 Jan 2011 11:39:53 +0100
branchstable
changeset 6880 4be32427b2b9
parent 6424 f443a2b8a5c7
child 7529 2fdc310be7cd
permissions -rw-r--r--
[book] fixes some references and other doc construction pbs * predefine order of js files in index generation, skip some files * fix some references to the base tutorial (recently changed) * other ReST fixes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     1
==========================
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     2
Use Windmill with CubicWeb
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     3
==========================
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     4
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     5
Windmill_ implements cross browser testing, in-browser recording and playback,
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     6
and functionality for fast accurate debugging and test environment integration.
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     7
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     8
.. _Windmill: http://www.getwindmill.com/
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     9
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    10
`Online features list <http://www.getwindmill.com/features>`_ is available.
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    11
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    12
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    13
Installation
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    14
============
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    15
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    16
Windmill
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    17
--------
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    18
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    19
You have to install Windmill manually for now. If you're using Debian, there is
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    20
no binary package (`yet <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=579109>`_).
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    21
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    22
The simplest solution is to use a *setuptools/pip* command (for a clean
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    23
environment, take a look to the `virtualenv
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    24
<http://pypi.python.org/pypi/virtualenv>`_ project as well)::
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    25
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    26
    pip install windmill
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    27
    curl -O http://github.com/windmill/windmill/tarball/master
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    28
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5905
diff changeset
    29
However, the Windmill project doesn't release frequently. Our recommandation is
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5905
diff changeset
    30
to used the last snapshot of the Git repository:
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5905
diff changeset
    31
6183
fcb9d90b622e [doc] fix typo
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5995
diff changeset
    32
.. sourcecode:: bash
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5905
diff changeset
    33
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5905
diff changeset
    34
    git clone git://github.com/windmill/windmill.git HEAD
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5905
diff changeset
    35
    cd windmill
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5905
diff changeset
    36
    python setup.py develop
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5905
diff changeset
    37
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5905
diff changeset
    38
Install instructions are `available <http://wiki.github.com/windmill/windmill/installing>`_.
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    39
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    40
Be sure to have the windmill module in your PYTHONPATH afterwards::
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    41
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    42
    python -c "import windmill"
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    43
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    44
X dummy
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    45
-------
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    46
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    47
In order to reduce unecessary system load from your test machines, It's
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    48
recommended to use X dummy server for testing the Unix web clients, you need a
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    49
dummy video X driver (as xserver-xorg-video-dummy package in Debian) coupled
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    50
with a light X server as `Xvfb <http://en.wikipedia.org/wiki/Xvfb>`_.
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    51
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    52
    The dummy driver is a special driver available with the XFree86 DDX. To use
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    53
    the dummy driver, simply substitue it for your normal card driver in the
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    54
    Device section of your xorg.conf configuration file. For example, if you
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    55
    normally uses an ati driver, then you will have a Device section with
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    56
    Driver "ati" to let the X server know that you want it to load and use the
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    57
    ati driver; however, for these conformance tests, you would change that
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    58
    line to Driver "dummy" and remove any other ati specific options from the
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    59
    Device section.
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    60
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    61
    *From: http://www.x.org/wiki/XorgTesting*
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    62
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    63
Then, you can run the X server with the following command :
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    64
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    65
    /usr/bin/X11/Xvfb :1 -ac -screen 0 1280x1024x8 -fbdir /tmp
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    66
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    67
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    68
Windmill usage
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    69
==============
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    70
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    71
Record your use case
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    72
--------------------
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    73
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    74
- start your instance manually
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    75
- start Windmill_ with url site as last argument (read Usage_ or use *'-h'*
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    76
  option to find required command line arguments)
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    77
- use the record button
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    78
- click on save to obtain python code of your use case
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    79
- copy the content to a new file in a *windmill* directory
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    80
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    81
.. _Usage: http://wiki.github.com/windmill/windmill/running-tests
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    82
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    83
If you are using firefox as client, consider the "firebug" option.
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    84
5995
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
    85
If you have a running instance, you can refine the test by the *loadtest* windmill option:
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    86
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    87
    windmill -m firebug loadtest=<test_file.py> <instance url>
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    88
5995
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
    89
Or use the internal windmill shell to explore available commands:
5905
ed66f5a8d48a [test] windmill: add a timeout between JS assertion in test_creation use case
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    90
ed66f5a8d48a [test] windmill: add a timeout between JS assertion in test_creation use case
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    91
    windmill -m firebug shell <instance url>
ed66f5a8d48a [test] windmill: add a timeout between JS assertion in test_creation use case
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    92
ed66f5a8d48a [test] windmill: add a timeout between JS assertion in test_creation use case
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    93
.. sourcecode:: python
ed66f5a8d48a [test] windmill: add a timeout between JS assertion in test_creation use case
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    94
ed66f5a8d48a [test] windmill: add a timeout between JS assertion in test_creation use case
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    95
    >>> load_test(<your test file>)
ed66f5a8d48a [test] windmill: add a timeout between JS assertion in test_creation use case
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    96
    >>> run_test(<your test file>)
ed66f5a8d48a [test] windmill: add a timeout between JS assertion in test_creation use case
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    97
ed66f5a8d48a [test] windmill: add a timeout between JS assertion in test_creation use case
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    98
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    99
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   100
Integrate Windmill tests into CubicWeb
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   101
======================================
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   102
6424
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   103
Set environment
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   104
---------------
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   105
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   106
You have to create a new unit test file and a `windmill` directory and copy all
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   107
your windmill use case into it.
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   108
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   109
.. sourcecode:: python
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   110
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   111
    # test_windmill.py
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   112
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   113
    # Run all scenarii found in windmill directory
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   114
    from cubicweb.devtools.cwwindmill import (CubicWebWindmillUseCase,
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   115
                                              unittest_main)
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   116
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   117
    if __name__ == '__main__':
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   118
        unittest_main()
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   119
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   120
Run your tests
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   121
--------------
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   122
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   123
You can easily run your windmill test suite through `pytest` or :mod:`unittest`.
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   124
You have to copy a *test_windmill.py* file from :mod:`web.test`.
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   125
5995
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   126
To run your test series::
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   127
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   128
    % pytest test/test_windmill.py
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   129
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   130
By default, CubicWeb will use **firefox** as the default browser and will try
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   131
to run test instance server on localhost. In the general case, You've no need
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   132
to change anything.
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   133
6424
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   134
Check :class:`cubicweb.devtools.cwwindmill.CubicWebWindmillUseCase` for
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   135
Windmill configuration. You can edit windmill settings with following class attributes:
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   136
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   137
* browser
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   138
  identification string (firefox|ie|safari|chrome) (firefox by default)
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   139
* test_dir
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   140
  testing file path or directory (windmill directory under your unit case
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   141
  file by default)
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   142
* edit_test
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   143
  load and edit test for debugging (False by default)
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   144
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   145
Examples:
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   146
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   147
    browser = 'firefox'
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   148
    test_dir = osp.join(__file__, 'windmill')
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   149
    edit_test = False
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   150
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   151
If you want to change cubicweb test server parameters, you can check class
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   152
variables from :class:`CubicWebServerConfig` or inherit it with overriding the
6880
4be32427b2b9 [book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6424
diff changeset
   153
:attr:`configcls` attribute in :class:`CubicWebServerTC` ::
6424
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   154
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   155
.. sourcecode:: python
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   156
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   157
    class OtherCubicWebServerConfig(CubicWebServerConfig):
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   158
        port = 9999
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   159
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   160
    class NewCubicWebServerTC(CubicWebServerTC):
f443a2b8a5c7 [devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6324
diff changeset
   161
        configcls = OtherCubicWebServerConfig
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   162
5995
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   163
For instance, CubicWeb framework windmill tests can be manually run by::
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   164
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   165
    % pytest web/test/test_windmill.py
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   166
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   167
Edit your tests
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   168
---------------
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   169
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   170
You can toggle the `edit_test` variable to enable test edition.
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   171
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   172
But if you are using `pytest` as test runner, use the `-i` option directly.
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   173
The test series will be loaded and you can run assertions step-by-step::
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   174
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   175
    % pytest -i test/test_windmill.py
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   176
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   177
In this case, the `firebug` extension will be loaded automatically for you.
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   178
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   179
Afterwards, don't forget to save your edited test into the right file (no autosave feature).
b9c612274af7 [test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5924
diff changeset
   180
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   181
Best practises
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   182
--------------
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   183
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   184
Don't run another instance on the same port. You risk to silence some
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   185
regressions (test runner will automatically fail in further versions).
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   186
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   187
Start your use case by using an assert on the expected primary url page.
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   188
Otherwise all your tests could fail without clear explanation of the used
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   189
navigation.
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   190
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   191
In the same location of the *test_windmill.py*, create a *windmill/* with your
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   192
windmill recorded use cases.
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   193
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   194
6324
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   195
Caveats
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   196
=======
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   197
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   198
File Upload
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   199
-----------
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   200
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   201
Windmill can't do file uploads. This is a limitation of browser Javascript
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   202
support / sandboxing, not of Windmill per se.  It would be nice if there were
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   203
some command that would prime the Windmill HTTP proxy to add a particular file
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   204
to the next HTTP request that comes through, so that uploads could at least be
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   205
faked.
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   206
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   207
.. http://groups.google.com/group/windmill-dev/browse_thread/thread/cf9dc969722bd6bb/01aa18fdd652f7ff?lnk=gst&q=input+type+file#01aa18fdd652f7ff
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   208
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   209
.. http://davisagli.com/blog/in-browser-integration-testing-with-windmill
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   210
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   211
.. http://groups.google.com/group/windmill-dev/browse_thread/thread/b7bebcc38ed30dc7
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   212
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6183
diff changeset
   213
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   214
Preferences
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   215
===========
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   216
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   217
A *.windmill/prefs.py* could be used to redefine default configuration values.
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   218
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   219
.. define CubicWeb preferences in the parent test case instead with a dedicated firefox profile
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   220
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   221
For managing browser extensions, read `advanced topic chapter
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   222
<http://wiki.github.com/windmill/windmill/advanced-topics>`_.
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   223
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   224
More configuration examples could be seen in *windmill/conf/global_settings.py*
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   225
as template.
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   226
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
   227