doc/book/en/tutorials/tools/windmill.rst
branchstable
changeset 6424 f443a2b8a5c7
parent 6324 bdb85e3602c8
child 6880 4be32427b2b9
equal deleted inserted replaced
6420:4c14be06e557 6424:f443a2b8a5c7
    98 
    98 
    99 
    99 
   100 Integrate Windmill tests into CubicWeb
   100 Integrate Windmill tests into CubicWeb
   101 ======================================
   101 ======================================
   102 
   102 
       
   103 Set environment
       
   104 ---------------
       
   105 
       
   106 You have to create a new unit test file and a `windmill` directory and copy all
       
   107 your windmill use case into it.
       
   108 
       
   109 .. sourcecode:: python
       
   110 
       
   111     # test_windmill.py
       
   112 
       
   113     # Run all scenarii found in windmill directory
       
   114     from cubicweb.devtools.cwwindmill import (CubicWebWindmillUseCase,
       
   115                                               unittest_main)
       
   116 
       
   117     if __name__ == '__main__':
       
   118         unittest_main()
       
   119 
   103 Run your tests
   120 Run your tests
   104 --------------
   121 --------------
   105 
   122 
   106 You can easily run your windmill test suite through `pytest` or :mod:`unittest`.
   123 You can easily run your windmill test suite through `pytest` or :mod:`unittest`.
   107 You have to copy a *test_windmill.py* file from :mod:`web.test`.
   124 You have to copy a *test_windmill.py* file from :mod:`web.test`.
   112 
   129 
   113 By default, CubicWeb will use **firefox** as the default browser and will try
   130 By default, CubicWeb will use **firefox** as the default browser and will try
   114 to run test instance server on localhost. In the general case, You've no need
   131 to run test instance server on localhost. In the general case, You've no need
   115 to change anything.
   132 to change anything.
   116 
   133 
   117 Check the :class:`cubicweb.devtools.cwwindmill.CubicWebServerTC` class for server
   134 Check :class:`cubicweb.devtools.cwwindmill.CubicWebWindmillUseCase` for
   118 parameters and :class:`cubicweb.devtools.cwwindmill.CubicWebWindmillUseCase` for
   135 Windmill configuration. You can edit windmill settings with following class attributes:
   119 Windmill configuration.
   136 
       
   137 * browser
       
   138   identification string (firefox|ie|safari|chrome) (firefox by default)
       
   139 * test_dir
       
   140   testing file path or directory (windmill directory under your unit case
       
   141   file by default)
       
   142 * edit_test
       
   143   load and edit test for debugging (False by default)
       
   144 
       
   145 Examples:
       
   146 
       
   147     browser = 'firefox'
       
   148     test_dir = osp.join(__file__, 'windmill')
       
   149     edit_test = False
       
   150 
       
   151 If you want to change cubicweb test server parameters, you can check class
       
   152 variables from :class:`CubicWebServerConfig` or inherit it with overriding the
       
   153 :var:`configcls` attribute in :class:`CubicWebServerTC` ::
       
   154 
       
   155 .. sourcecode:: python
       
   156 
       
   157     class OtherCubicWebServerConfig(CubicWebServerConfig):
       
   158         port = 9999
       
   159 
       
   160     class NewCubicWebServerTC(CubicWebServerTC):
       
   161         configcls = OtherCubicWebServerConfig
   120 
   162 
   121 For instance, CubicWeb framework windmill tests can be manually run by::
   163 For instance, CubicWeb framework windmill tests can be manually run by::
   122 
   164 
   123     % pytest web/test/test_windmill.py
   165     % pytest web/test/test_windmill.py
   124 
   166