Agile development?

248 views
Skip to first unread message

Oisin Mulvihill

unread,
Jan 30, 2008, 1:45:27 PM1/30/08
to web2py Web Framework
Hi,

I came across your web framework and dutifully skimmed through the
docs and watched the video. I'm quite impressed with what I see and
the things you can do. I've been developing web applications on
various "frameworks" for more then 10 years. I like the way it all
hangs together. Your framework reminds me a lot of zope and
development applications for it.

However the thing that sticks out particularly when I look at the
video, is the complete lack of any testing focus. When your site
mentions "agile development" what I expect to see is a test driven
development. What would be really great is if you could actually
integrate unit and acceptance testing (maybe via selenium) into you
framework. Allowing you to populate the database with test data,
created from scripts, then exercise the app and validate its
responses. Development of new projects could start with coding tests
to capture the features your going to implement. If you then had an
admin screen which could verify the app and show green for all test
passing I would be very impressed. For simple applications /
prototyping the approach to development shown in the video is great.
However to do any serious sustainable software development you need to
be able to verify the functionality and behavior of your code and
(web) application features.

I realise as I type this email, that this is sounding more and more
like a rant against your framework. I don't really intend this as I
like a lot of the features I've seen. I guess I see your framework
highlighting a general problem I see in the software development
industry. A problem that it seems bent on sticking to the waterfall
approach to software development. I should say at this point that I'm
a big advocate of the agile/extreme programming methodology. I also
make a point of following the test driven approach and using it from
the beginning of any projects I'm involved in. From my point of view
no serious development can be done unless you take at least the test
first approach.

What are your views on this?

All the best,

Oisin

Massimo Di Pierro

unread,
Jan 30, 2008, 1:54:45 PM1/30/08
to web...@googlegroups.com
I agree with you.
this issue was discussed once on this mailing list. within web2py it
is possible to write doctest strings for controllers and it is
possible to write a test controllers that runs all the test strings.
Unfortunately this is undocumented. It is on my agenda to explain it
better and perhaps make such test controller part of the framework.

Actually it would be easy to write a red/green controller as you
suggest using doctest strings. I will try to make it part of next
version.

Massimo

voltron

unread,
Jan 30, 2008, 1:57:42 PM1/30/08
to web2py Web Framework
That would be awesome :-)

mdipierro

unread,
Jan 30, 2008, 8:45:16 PM1/30/08
to web2py Web Framework
For now I am reposting the current suggested solution to this problem.
Not elegant but it works...

If you are looking for a quick way to test you controllers you can do
the following

def example(): ### sample controller
"""
>>> example() ### this is a test
4
"""
return 3

def _test(): ### testing controller
import doctest, gluon.fileutils, sys, StringIO
if not gluon.fileutils.check_credentials(request): raise HTTP(400)
stdout=sys.stdout
sys.stdout=StringIO.StringIO()
print '<pre>'
#### add one line for each controller to test
doctest.run_docstring_examples(example,globals(),True) ### test
example
####
print '</pre>'
s=sys.stdout.getvalue()
sys.stdout=stdout
return dict(report=XML(s))

If (and only if) you are logged in as admin you can access the
function _test in your controller and it will run tests for the
controllers listed, for examples this tests the controller example

doctest.run_docstring_examples(example,globals(),True)

Eventually you will not need this test controller to do the testing.

Massimo

Massimo Di Pierro

unread,
Feb 1, 2008, 11:36:00 PM2/1/08
to web...@googlegroups.com
I think I have addressed the testing issue. Check out the latest version of web2py at

   code.google.com/p/web2py (revision 28)

under http://localhost:8000/admin/default/design/[yourapp], under Controllers you will now find a new 
  
   [ test ] 

button. Try writing something like this in a controller

def index():
     """
     this is a doctest
     >>> import time; time.sleep(5)
     >>> index()
     2
     """
     return 1

then go in admin and press the [ test ] button. You will be impressed!

Here is a screenshot 
although it does not really gives justice to the work done.
(and being stuck at the airport for 6 hours really helped in getting this done).

Please check that it works for you. There is one caveat, your app may block testing if it performs a redirection outside controller functions. I will explain when/if the issue shows up.

Massimo

On Jan 30, 2008, at 12:45 PM, Oisin Mulvihill wrote:

voltron

unread,
Feb 2, 2008, 9:15:17 AM2/2/08
to web2py Web Framework
Thats great. Can one call the tests also from the commandline?

On Feb 2, 5:36 am, Massimo Di Pierro <mdipie...@cs.depaul.edu> wrote:
> I think I have addressed the testing issue. Check out the latest
> version of web2py at
>
> code.google.com/p/web2py (revision 28)
>
> underhttp://localhost:8000/admin/default/design/[yourapp], under
> Controllers you will now find a new
>
> [ test ]
>
> button. Try writing something like this in a controller
>
> def index():
> """
> this is a doctest
> >>> import time; time.sleep(5)
> >>> index()
> 2
> """
> return 1
>
> then go in admin and press the [ test ] button. You will be impressed!
>
> Here is a screenshothttp://groups.google.com/group/web2py/web/test.tiff
Reply all
Reply to author
Forward
0 new messages