plone / plone.act

DEPRECATED Acts, not words : ACceptance Testing for Plone
2 stars 2 forks source link

Support writing tests with RIDE #30

Closed datakurre closed 11 years ago

datakurre commented 11 years ago

RIDE is visual Robot Framework IDE for writing and running robot tests.

Currently, it's not very pretty and it's a bit hard to get installed (requires wxPython). Yet, eventually it might ease writing test, because it should help to discover the existing keywords (and their documentation).

I didn't yet manage to get RIDE configured to discover selenium2library and plone.act -keywords from a buildout, but I understood, that there were options for setting python-paths and custom robot-script to make everything possible.

Currently, you cannot pass a custom configuration file for RIDE.

Yet, we could have a conditional buildout-part, which creates a RIDE-configuration file with buildout-eggs in python paths and executes pybot from our buildout. Or maybe even install ride under buildout?

Would @saily be interested trying this out?

What I'm trying to achieve is that, a new developer could just

Of course, not sure, if that will work. Just looking for options where one could try plone.act without need to create plone.app.testing-layer, wrapper test suites etc. before writing any tests. (Yes, I've been trying to listen to the criticism about robotsuite/zope.testrunner-approach.)

saily commented 11 years ago

I'll give that a try

saily commented 11 years ago

Basically this is possible...

How i got running tests through RIDE

  1. I added a new section into buildout (this is already configured in master/buildout.cfg file of plone.act)

    [buildout]
    ...
    parts = 
       ...
       pybot
    
    [pybot]
    recipe = zc.recipe.egg
    eggs =
       plone.act [test]
       robotentrypoints
    initialization =
       import os
       os.environ.setdefault("ZSERVER_PORT", "8080")
       os.environ.setdefault("PLONE_SITE_ID", "Plone")
       os.environ.setdefault("SITE_OWNER_NAME", "admin")
       os.environ.setdefault("SITE_OWNER_PASSWORD", "admin")
  2. Modify variables.py to load SITE_OWNER_NAME and SITE_OWNER_PASSWORD from environment.
  3. Run bin/pybot --argumentfile src/plone.act/.../keywords.txt --include [tag] [testfile]
  4. Add the same configuration to RIDE custom script.
  5. Click on the Start Button in RIDE

Not working

RIDE's configuration Skip tests with these tags and Only run tests with these tags did not work for me, but you can add --include or --exclude as arguments for custom script.

datakurre commented 11 years ago

I believe, if we could configure working --listener parameter for the pybot calls in RIDE, our act_server would make RIDE really usable:

https://ploneact.readthedocs.org/en/latest/server.html

datakurre commented 11 years ago

@saily I've been struggling to build wxPython in buildout to get a buildout with RIDE. If we'd manage to do that, then with act_server (or robot-server in p.a.robotframework) we would have complete RIDE support.

These steps will build wxPython for OSX, but there's still something missing...

[wxPython-post-make-hook]
recipe = collective.recipe.template
input = inline:
    import os
    import sys
    import subprocess
    wxpython_post_make_hook = lambda o, b:\
        subprocess.call([sys.executable, 'setup.py',\
            'WX_CONFIG=%s' % os.path.join(o['location'], 'bin', 'wx-config'),\
            'WXPORT=osx_cocoa', 'CORE_ONLY=1', 'install', '--home=%s' %\
            o['location'],], cwd=os.path.join(os.getcwd(), 'wxPython'))
output = ${buildout:parts-directory}/hooks.py

[wxPython]
# Thanks to: http://geekscrap.com/2010/01/install-wxpython-in-buildout/
recipe = hexagonit.recipe.cmmi
url = http://downloads.sourceforge.net/wxpython/wxPython-src-2.9.4.0.tar.bz2
post-make-hook = ${buildout:parts-directory}/hooks.py:wxpython_post_make_hook
keep-compile-dir = true
configure-options =
    --enable-optimise
    --enable-display
    --enable-geometry
    --with-libjpeg=builtin
    --with-libpng=builtin
    --with-libtiff=builtin
    --with-zlib=builtin
# OSX:
    --enable-framework
    --with-osx_cocoa
# Linux:
#   --with-gtk2
saily commented 11 years ago

hi, thanks for sharing this! We should target wxPython 2.8 because RIDE crashes with an segmentation fault on 2.9. see: http://code.google.com/p/robotframework-ride/issues/detail?id=888 Try to figure out what else we need.

datakurre commented 11 years ago

Oh, I missed that one. Many options will look different for 2.8 build, because cocoa vs. carbon.

The missing thing is this:

This program needs access to the screen.
Please run with a Framework build of python, and only when you are
logged in on the main display of your Mac.

I'm not sure if there's any way to get wxPython working without installing it as "system python", but I still wish that there is a way.

The alternative for getting nice RIDE experience is to install all required robot libraries into system wide wxPython installation and I really wish that there's a better approach.

The optimal would be a buildout that would create ride.py with sys.path including both wxPython and buildout paths (p.a.testing, robot libraries and develop products, etc...).

datakurre commented 11 years ago

Too bad, 2.8 cannot be built for current OSX version without installing an old Xcode version. For example: https://trac.macports.org/ticket/37215

I think, that's no go for that approach.

The next best thing would be to hack virtualenv with wxPython...

I still would like to get RIDE started with buildout-generated sys.paths to make it easier to use custom libraries with it.

datakurre commented 11 years ago

Of course, 2.8 won't work on 64bit OSX environment... (Why has this be this hard :P)

saily commented 11 years ago

hmm, what about posting that on ride googlecode page and find a voluntary helping us... for someone who's into ride's code it shouldn't be too hard implementing wxPython 2.9 support.

datakurre commented 11 years ago

2.9 support is already work in progress: http://code.google.com/p/robotframework-ride/issues/detail?id=888#c22

datakurre commented 11 years ago

Done (in p.a.robotframework). https://github.com/plone/plone.app.robotframework/blob/master/buildout-ride.cfg

@saily

The key is to set the RIDE startup script to use system python to give wx-libraries access to display and all magic they need (at least on OSX).

https://github.com/plone/plone.app.robotframework/blob/master/buildout-ride.cfg

  1. You may install wxPython in the way you like (and get 2.8 if it works on your system).
  2. Just set the RIDE startup script to use the system python (/usr/bin/pythonw if you have installed wxPython globally, /usr/bin/python when you compile wxPython in buildout)
  3. IF you build wxPython in buildout, you must also set LD_LIBRARY_PATH for the RIDE startup script.
  4. Buildout cannot create startup script for RIDE, so a few extra lines (entry-points, scripts and arguments) are needed to create the startup script properly.

At the end you should have bin/ride-script with both wx-libraries and buildout eggs available.

And finally, how to run tests with RIDE and p.a.robotframework:

  1. Start robot-server with your test layer bin/robot-server my.product.testing.ROBOT_TESTING
  2. Start RIDE bin/ride
  3. Select custom script for executing tests and browse to select bin/robot from the buildout
  4. Write tests and run them from RIDE!

Why bin/robot instead of pybot? Because bin/robot is a shortcut for pybot with --listener plone.app.robotframework.RobotListener and that enables plone(.app).testing's test isolation with bin/robot-server.

It's even possible to use RIDE to run Plone-tests at SauceLabs (just tried that out), but that might need a little more documentation :)

saily commented 11 years ago

Good job!