Discussion:
Lot of work in the testing framework for web applications?
Paolo Bizzarri
2002-03-27 16:09:32 UTC
Permalink
Hi everyone,

we are developing a B2B application using python and Zope, and we are
trying the test-first approach in the development.

It seems that there is a lot of work to do in the development of the
testing framework, even for testing simple parts of the applications.

Either I am wrong with the granularity of the whole, or I am using the
wrong approach.

Have someone some experience on this ?

Best regards

Paolo
--
Paolo Bizzarri - Presidente - Icube S.r.l.
Sede: Via Ridolfi 15 - 56124 Pisa (PI), Italia
E-mail: ***@icube.it WWW: www.icube.it
Tel: (+39) 050 97 02 07 Fax: (+39) 050 31 36 588


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Laurent Bossavit
2002-03-27 15:59:34 UTC
Permalink
Post by Paolo Bizzarri
It seems that there is a lot of work to do in the development of the
testing framework, even for testing simple parts of the applications.
How do you mean that ? There's a testing framework for Python
already, PyUnit, unless I'm mistaken. Are you aware of it, and if so
what else is there to develop in the way of a testing framework ?


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Paolo Bizzarri
2002-03-27 17:02:31 UTC
Permalink
Hi Laurent,
Post by Laurent Bossavit
Post by Paolo Bizzarri
It seems that there is a lot of work to do in the development of the
testing framework, even for testing simple parts of the applications.
How do you mean that ? There's a testing framework for Python
already, PyUnit, unless I'm mistaken. Are you aware of it, and if so
what else is there to develop in the way of a testing framework ?
Yes, I know PyUnit, and my testing framework is going to be built on top
of this.

However, for our applications PyUnit seems a bit too weak.

Our applications are based on the application server Zope, are web based
and integrated with relational database.

Typically, an user select a link built from a SQL query and access a page
of data, on which he performs some action.

With this domain, PyUnit seems a bit too weak, as I have to do a lot of
setup for trying even simple things.

Have someone done something on this ?

Best regards.

Paolo
--
Paolo Bizzarri - Presidente - Icube S.r.l.
Sede: Via Ridolfi 15 - 56124 Pisa (PI), Italia
E-mail: ***@icube.it WWW: www.icube.it
Tel: (+39) 050 97 02 07 Fax: (+39) 050 31 36 588


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Laurent Bossavit
2002-03-27 16:54:17 UTC
Permalink
Post by Paolo Bizzarri
Our applications are based on the application server Zope, are web
based and integrated with relational database.
That's a lot of infrastructure. I'm hoping, for your sake, that all that
infrastructure comes with a lot of tests of its own. You know where
the bugs are : they are where there aren't enough tests.
Post by Paolo Bizzarri
Typically, an user select a link built from a SQL query and access a
page of data, on which he performs some action.
I'm not sure I see the business value in that. (I can be a bit annoying
that way.) Can you tell the title of one of your user stories, maybe a
couple sentences if there is that much written down ?
Post by Paolo Bizzarri
With this domain, PyUnit seems a bit too weak, as I have to do a lot of
setup for trying even simple things.
I wouldn't hold this against PyUnit. :)

What could it mean that doing simple things is more painful than it
should be ?
Post by Paolo Bizzarri
Have someone done something on this ?
I once wrote a non-trivial Web application for content management,
XML-based, using JSP, XML, and an SQL relational database. It
was my first XPish project, SoloXP in fact.

That app supported (and to the best of my knowledge still supports)
the regional corporate site of one of the Big Five (soon to be Fat
Four) accountancies.

What I did, what I learned...

I ended up ditching JSP because it was making things too hard to
test as I moved toward "user interfaces in HTML" at the customers'
requests.

I made a baaaaad mistake trying to implement a generic framework
for editing XML content, based on XML Schema definitions. This
thing never worked well.

I didn't get along too well with the Sybase DB, and for testing I used
a neat little thing called HypersonicSQL instead, which uses text
files and is much faster. The production version used Sybase, was
slower, and needed huge amounts of memory.

I used XML Tidy and XPath with some success and satisfaction in
the acceptance tests, to get a normalized XML version of the pages
I generated, and express the appropriate assertions concerning the
pages as XPath queries. I would consider using that approach
again.

Hope this helps...


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Paolo Bizzarri
2002-03-27 17:40:02 UTC
Permalink
Hi Laurent,
Post by Paolo Bizzarri
Our applications are based on the application server Zope, are web >
based and integrated with relational database.
That's a lot of infrastructure. I'm hoping, for your sake, that all that
infrastructure comes with a lot of tests of its own. You know where
the bugs are : they are where there aren't enough tests.
Well, I am using Zope and Postgres, and they seems both well tested. Zope
at least includes unit test of its own..
Post by Paolo Bizzarri
Typically, an user select a link built from a SQL query and access a
page of data, on which he performs some action.
I'm not sure I see the business value in that. (I can be a bit annoying
that way.) Can you tell the title of one of your user stories, maybe a
couple sentences if there is that much written down ?
Ok, here is a simple user story:

- the responible of the office has to authorize companies to perform
purchases through the web; they can be authorized to categories,
subcategories and single products;


This for us will become a set of web pages, one for selecting the company,
one for selecting the category and one for the subcategories.
Post by Paolo Bizzarri
With this domain, PyUnit seems a bit too weak, as I have to do a lot of
setup for trying even simple things.
I wouldn't hold this against PyUnit. :)
I agree. Probably I am using PyUnit in the "wrong" way, so things are too
much complicated.
Post by Paolo Bizzarri
What could it mean that doing simple things is more painful than it
should be ?
Have someone done something on this ?
<snip>

The example you propose is interesting. I will examine in detail and
provide feedback.

Best regards.

Paolo
--
Paolo Bizzarri - Presidente - Icube S.r.l.
Sede: Via Ridolfi 15 - 56124 Pisa (PI), Italia
E-mail: ***@icube.it WWW: www.icube.it
Tel: (+39) 050 97 02 07 Fax: (+39) 050 31 36 588


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
banshee858
2002-03-27 17:24:48 UTC
Permalink
In our ASP world we avoided testing the HTML pages by unit tests and
pushed those issues to AT. We use HTML pages to gather data and
present results from the DB; if you cannot perform an AT objective,
it is likely that the error is on the HTML page with odd business
logic or the method is called or loaded incorrectly on the HTML
page. I believe there is some way to test the HTML using unit tests
(HttpUnit??). We never went down that route, but I would like to
learn how that works.

All the work manipulating the data gathered from the Request.Form,
Request.Querystring, etc., etc. happens in classes and
methods...these are the items that are unit tested. We have tried to
decopule the business logic from the presentation as much as you can
in ASP and I would say we are 50% to 60% there.

In my opinion, if you can decouple the business logic from the
presentation layer, it is easier to test everything that can possibly
break. If you put too much complex business logic in the
HTML/presentation layer, you are giving too much responsibility to
the AT. Simple business logic (True/False checks or simple If/Then)
seems to work fine, but often these are the areas that fail.

As for a testing framework, we created our own testing framework
based on JUnit. Since with ASP, the code is "complied" when you load
a webpage, we run the tests on an ASP page dedicated for tests only.
If you would like to see how we use this framework and some tests, I
would be more than happy to share it. Nothing in it is proprietary
since it is based off of JUnit.

As to how to implement XP, I agree with Laurent, We need some more
information. Who wants XP? You? The boss (are you the boss)? The
other programmers? Your degree of success will depend who is
sponsoring this trial.


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
banshee858
2002-03-27 17:25:33 UTC
Permalink
In our ASP world we avoided testing the HTML pages by unit tests and
pushed those issues to AT. We use HTML pages to gather data and
present results from the DB; if you cannot perform an AT objective,
it is likely that the error is on the HTML page with odd business
logic or the method is called or loaded incorrectly on the HTML
page. I believe there is some way to test the HTML using unit tests
(HttpUnit??). We never went down that route, but I would like to
learn how that works.

All the work manipulating the data gathered from the Request.Form,
Request.Querystring, etc., etc. happens in classes and
methods...these are the items that are unit tested. We have tried to
decopule the business logic from the presentation as much as you can
in ASP and I would say we are 50% to 60% there.

In my opinion, if you can decouple the business logic from the
presentation layer, it is easier to test everything that can possibly
break. If you put too much complex business logic in the
HTML/presentation layer, you are giving too much responsibility to
the AT. Simple business logic (True/False checks or simple If/Then)
seems to work fine, but often these are the areas that fail.

As for a testing framework, we created our own testing framework
based on JUnit. Since with ASP, the code is "complied" when you load
a webpage, we run the tests on an ASP page dedicated for tests only.
If you would like to see how we use this framework and some tests, I
would be more than happy to share it. Nothing in it is proprietary
since it is based off of JUnit.

As to how to implement XP, I agree with Laurent, We need some more
information. Who wants XP? You? The boss (are you the boss)? The
other programmers? Your degree of success will depend who is
sponsoring this trial.


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Laurent Bossavit
2002-03-27 17:42:57 UTC
Permalink
Post by Paolo Bizzarri
- the responible of the office has to authorize companies to perform
purchases through the web; they can be authorized to categories,
subcategories and single products;
Ah, purchasing. OK, I've got a better feel for it now.
Post by Paolo Bizzarri
This for us will become a set of web pages, one for selecting the
company, one for selecting the category and one for the subcategories.
Wait a minute... It seems to me that just being able to see a list of
companies that the head office is overseeing would have value. If
nothing else, it would be a reminder of what's in the system.

If your customer agreed with me (maybe she has, and you have a
story that's just like that) there would be a smaller story split from
the large one, with fewer things to test for. In pJava(*) I'd do it that
way :

CompanyRosterTest
public testListWithOneCpy
roster.add(new Company("Bits Inc."))
assertEquals("<TABLE><TR><TD>Bits
Inc.</TD></TR></TABLE>",roster.listInHtml());

and I'm sure something just as small can be written in Python. No
heavy setup, just objects talking to each other.

OK, the HTML isn't what the customer would want. This is a unit
test, right ? So in an acceptance test, I'd test for better-looking
HTML. That would lead to lots of duplicated data : for instance
TABLE, TR, and TD are each duplicated once in the above.

If I concentrated on getting tests passing and failing, and refactoring
even the tests, and maybe with a little help from my friends (XML,
XPath) I'm sure I'd eventually build up a small but useful set of
HTML-testing methods. (Maybe even classes !)

What about the SQL database, you say ? To which I answer, I don't
know. That would depend on how you're testing the story for which
the simplest implementation is an SQL database. Which means that
you have a test which you *cannot* get to pass unless you have an
SQL database, as opposed to something simpler like a text file, or
serialized objects or somesuch.

What was the *first* story you did ?

(*) pJava is my pseudo-Java with a syntax that's more readable in
emails. It also means I've never actually compiled or executed the
code I'm posting. I try not to do too much of that - posting code I
haven't actually seen compile and run.


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Charlie Poole
2002-03-27 19:51:16 UTC
Permalink
Laurent,
Post by Laurent Bossavit
(*) pJava is my pseudo-Java with a syntax that's more readable in
emails. It also means I've never actually compiled or executed the
code I'm posting. I try not to do too much of that - posting code I
haven't actually seen compile and run.
Hmmm... I recently posted what appeared to be some incorrect Ruby.
Now I realize it was actually correct cpRuby. :-)

Charlie Poole
***@pooleconsulting.com


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Bill de hÓra
2002-03-28 00:15:23 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-----Original Message-----
What I did, what I learned...
I ended up ditching JSP because it was making things too hard to
test as I moved toward "user interfaces in HTML" at the
customers' requests.
Can you say more about this?
I made a baaaaad mistake trying to implement a generic framework
for editing XML content, based on XML Schema definitions. This
thing never worked well.
Can you say more about this too?
I used XML Tidy and XPath with some success and satisfaction in
the acceptance tests, to get a normalized XML version of the
pages I generated, and express the appropriate assertions
concerning the pages as XPath queries. I would consider using
that approach
again.
Cool. I've done trivial hand tests using Xpaths, and I've been
thinking about hacking junit to allow assertions to be written as
XPaths for a while now.

Bill de hÓra

-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.4

iQA/AwUBPKJgl+aWiFwg2CH4EQKjkACghMIqvdedKmFmyD0VdfwK2JGviqcAoIwQ
37l36g/4mtsCl0nes5d+Gzkk
=XHLZ
-----END PGP SIGNATURE-----


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Bryan Dollery
2002-03-28 00:30:38 UTC
Permalink
Hi Bill,
Post by Bill de hÓra
Cool. I've done trivial hand tests using Xpaths, and I've been
thinking about hacking junit to allow assertions to be written as
XPaths for a while now.
Why not just write an XML_Unit?

Bryan

b r y a n d o l l e r y | c e o
c h a o s e n g i n e e r s
+64 (0)21 330607
http://www.ChaosEngineers.co.nz



[Non-text portions of this message have been removed]


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Bill de hÓra
2002-03-28 01:05:45 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-----Original Message-----
Sent: 28 March 2002 00:31
Subject: RE: [XP] Lot of work in the testing framework for
web applications?
Hi Bill,
Post by Bill de hÓra
Cool. I've done trivial hand tests using Xpaths, and I've been
thinking about hacking junit to allow assertions to be written
as XPaths for a while now.
Why not just write an XML_Unit?
Could do. But eventually you're going to have to target some
programming langauge and I'd rather avoid XSLT and not wait for XML
Query. Maybe an Ant task is the thing to do.

Bill de hÓra

-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.4

iQA/AwUBPKJsZ+aWiFwg2CH4EQJraACeOGuan21WCPS45rhWesECHHH5AsUAoN27
6wpNaPQ3G6j2fCH4o6Zfc2DX
=utzg
-----END PGP SIGNATURE-----


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
a***@jguru.com
2002-03-28 17:53:30 UTC
Permalink
Post by Bill de hÓra
Post by Laurent Bossavit
I used XML Tidy and XPath with some success and satisfaction in
the acceptance tests, to get a normalized XML version of the
pages I generated, and express the appropriate assertions
concerning the pages as XPath queries. I would consider using
that approach
again.
Cool. I've done trivial hand tests using Xpaths, and I've been
thinking about hacking junit to allow assertions to be written as
XPaths for a while now.
We're using XPath and HTTPUnit for testing HTML. It's fun. Now that
we've got some code, we're thinking of defining some config file, but
we've already got assertXPathEquals which may be sufficient. It beats
hell out of walking the DOM.

In order to help learn/teach XPath, I wrote XPath Explorer. Please
take a look at http://www.purpletech.com/xpe and let me know if it's
useful, or could be useful. It'd be neat if we could collaborate on
designing a Web testing framework, or just some tools, based on XPath.

For example, I want to extend XPE so I can select a node, click "build
test," and get an XPath pointing to that node, and some JUnit source
code that asserts its value is something.

- A
--
Alex Chaffee mailto:***@jguru.com
jGuru - Java News and FAQs http://www.jguru.com/alex/
Creator of Gamelan http://www.gamelan.com/
Founder of Purple Technology http://www.purpletech.com/
Curator of Stinky Art Collective http://www.stinky.com/

To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Bill de hÓra
2002-03-28 18:03:37 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-----Original Message-----
We're using XPath and HTTPUnit for testing HTML. It's fun.
Now that we've got some code, we're thinking of defining some
config file, but we've already got assertXPathEquals which
may be sufficient. It beats hell out of walking the DOM.
:)
In order to help learn/teach XPath, I wrote XPath Explorer.
Please take a look at http://www.purpletech.com/xpe and let
me know if it's useful, or could be useful. It'd be neat if
we could collaborate on designing a Web testing framework, or
just some tools, based on XPath.
Cool. Will do.

Bill de hÓra

-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.4

iQA/AwUBPKNa9uaWiFwg2CH4EQL4nACcDZwzG96p7nfhWGA9psA/sxxvT2EAoMup
V4CPQ6xy54PY6pEbErucKPNz
=0DUF
-----END PGP SIGNATURE-----


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Laurent Bossavit
2002-03-28 08:38:24 UTC
Permalink
Post by Bill de hÓra
Post by Laurent Bossavit
I ended up ditching JSP because it was making things too hard to
test as I moved toward "user interfaces in HTML" at the
customers' requests.
Can you say more about this?
Yes. There's one post from waaay back where I described some of
it, but I for one can't be bothered to try and track it down using the
Yahoo interface's bletcherous search engine, so I'll just repeat
myself. (O the horror.)

One of the bigger stories called for a user interface component that
looked a lot like JTable, for those who know, or ListPresenter with all
the fancy options - multiple columns, sorting, etc. I needed to have
buttons and checkboxes and whatnot inside those columns, too. All
(gasp) in HTML.

Some of the previous stories had been leading up to this, so I wasn't
entirely taken by surprise, but the thing was : all my tests for this
stuff were "on the other side" of the code, fetching the HTML via the
application server and examining it using XPath queries.

This was fine as it went, for acceptance testing, but I realized I had
almost *no* unit tests for the "view" code, that which was generating
the HTML. The "model" code was tested more or less thoroughly,
but the user interface was bits and pieces of HTML inside JSP
pages.

I don't know how to unit test JSP pages. So, I reasoned, one way to
make this whole mess easier to unit test was to perform the Move
Data Into Code refactoring :

<TABLE><TD><TR>
<%= user.getName() %>
</TR></TD></TABLE>

became

out.println("<TABLE><TD><TR>");
out.println(user.getName());
out.println("</TABLE></TD></TR>");

Aaaah, relief. The latter is something I know how to unit test, know
how to refactor, know how to design. Notice the duplication of
"TABLE" and "TABLE" ? In JSP I was up the creek without a paddle,
if I wanted to refactor that properly. In Java, of course, it's a piece of
cake.

So I moved all of the JSP crap into literal Strings in my classes,
started removing duplication, and pretty soon I had, if I say so
myself, a rather pretty set of View classes - Table, Button, little stuff
like that. All with decent unit tests.

Lesson learned : if you use a "language", or pseudo-language, for
which you don't have a unit testing framework, and decent
refactoring granularity, guess where defects will start accumulating ?
So don't do that. Stick with your best tools, your Smalltalk or your
Java or even your VB or C++.


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Paolo Bizzarri
2002-03-28 16:24:35 UTC
Permalink
Hi Laurent,

<snip>
Post by Laurent Bossavit
I don't know how to unit test JSP pages. So, I reasoned, one way to
make this whole mess easier to unit test was to perform the Move
<TABLE><TD><TR>
<%= user.getName() %>
</TR></TD></TABLE>
became
out.println("<TABLE><TD><TR>");
out.println(user.getName());
out.println("</TABLE></TD></TR>");
Aaaah, relief. The latter is something I know how to unit test, know
how to refactor, know how to design. Notice the duplication of
"TABLE" and "TABLE" ? In JSP I was up the creek without a paddle,
if I wanted to refactor that properly. In Java, of course, it's a piece of
cake.
I would like to know your opinion for a similar problem in Zope.

In Zope, you define a set of objects (stored in a specib ODB), that
contains various things, like:

- templates for HTML pages;
- connections to relational DBs;
- SQL queries;
- Python scripts.

Ideally, you are going to build presentation using templates, get/put data
in the DB using SQL queries, and perform business logic using Python
scripts.

In this scenario you seem to suggest that it could be a better choice to
move things from the templates directtly to the Python scripts (or to
extenrnal Python classes, that are always possible).

Can you confirm my impression ?

Best regards.

Paolo
--
Paolo Bizzarri - Presidente - Icube S.r.l.
Sede: Via Ridolfi 15 - 56124 Pisa (PI), Italia
E-mail: ***@icube.it WWW: www.icube.it
Tel: (+39) 050 97 02 07 Fax: (+39) 050 31 36 588


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Laurent Bossavit
2002-03-28 16:15:14 UTC
Permalink
Post by Paolo Bizzarri
I would like to know your opinion for a similar problem in Zope.
Sure. My opinion is free, and well worth that. :)
Post by Paolo Bizzarri
Ideally, you are going to build presentation using templates, get/put
data in the DB using SQL queries, and perform business logic using
Python scripts.
I'm still not sure I understand how that is "ideal", but I'm a slow
learner, mind you... I gather that this is one way to use Zope, though
possibly there are other options.
Post by Paolo Bizzarri
In this scenario you seem to suggest that it could be a better choice
to move things from the templates directtly to the Python scripts (or
to extenrnal Python classes, that are always possible).
Yes, that's what I suggested. That's what I would try in Zope, if I
ever worked with it, and if I had to unit test code that generated
complex pages. Maybe it wouldn't work... Though I would be very,
very surprised if it didn't.


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Jonas Bengtsson
2002-03-28 16:30:31 UTC
Permalink
Post by Laurent Bossavit
Post by Paolo Bizzarri
In this scenario you seem to suggest that it could be a better choice
to move things from the templates directtly to the Python scripts (or
to extenrnal Python classes, that are always possible).
Yes, that's what I suggested. That's what I would try in Zope, if I
ever worked with it, and if I had to unit test code that generated
complex pages. Maybe it wouldn't work... Though I would be very,
very surprised if it didn't.
Laurent,

Almost everyone recommends that one uses templates (e.g. Velocity for
servlets, ZPT for Zope) when developing web applications. The main
reason seems to be maintainability.. Writing inline html output in
servlets leads to cluttered code. However, I have no experience unit
testing web apps.
In most template languages there is a context which all data is
assigned to:

req -> servlet -(assigns data)-> context <-(reads data)- template
res <-(renders)-/

Can't you unit testing by just mocking out the template-engine?

Best regards,
Jonas

When you come to a fork in the road, take it!
- Yogi Berra


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Mike Beedle
2002-03-28 17:16:39 UTC
Permalink
Post by Paolo Bizzarri
Post by Laurent Bossavit
Post by Paolo Bizzarri
In this scenario you seem to suggest that it could be a better choice
to move things from the templates directtly to the Python scripts (or
to extenrnal Python classes, that are always possible).
Yes, that's what I suggested. That's what I would try in Zope, if I
ever worked with it, and if I had to unit test code that generated
complex pages. Maybe it wouldn't work... Though I would be very,
very surprised if it didn't.
Laurent,
Almost everyone recommends that one uses templates (e.g. Velocity for
servlets, ZPT for Zope) when developing web applications. The main
reason seems to be maintainability.. Writing inline html output in
servlets leads to cluttered code. However, I have no experience unit
testing web apps.
In most template languages there is a context which all data is
req -> servlet -(assigns data)-> context <-(reads data)- template
res <-(renders)-/
Can't you unit testing by just mocking out the template-engine?
Jonas, Laurent:

We have tried both. Templates definitely work but then you can't
take advantage of things like JSP tags, specially the Taglibs project
in Jakarta or the tag libs in Struts.

On the other hand, we found it is possible to use JSPs, but you have
to follow strict rules to render stuff:

* call the servlet (application) first and only use the JSPs
for display.
* avoid calling data retrieval, or transactional stuff directly
from the JSPs, instead put results in a model.
* never embed Java code in the JSP, instead always use helper
methods in a renderer or utility class
* if you use a JSP tag, follow the rule above
* use nested tags for advertising more complex visual components
* avoid Javascript whenever possible (applies to templates as well)
* use a framework that introspects inputs like our EAN (enterprise
agent network), or Struts, etc.
* avoid putting things in the session, use the "request" scope
to pass the model whenever possible to the JSP
* in most app servers, there are options to cache JSPs, use them
* use the "<@include file...>", instead of the "<jsp include ...>
directive. This will ensure pre-compiled JSP pages instead
of individual runtime renderings for each JSP
* etc.

If you follow the rules above, JSPs become simply rendering code that
is more or less manageable,

- Mike
http://www.hipaaccelerator.com
http://www.e-architects.com
http://www.xbreed.net


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Bill de hÓra
2002-03-28 17:48:41 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Here's a jsp WikiPage template that might make Mike's best
practices clearer:

<%@ page contentType='text/html; charset=UTF-8' %>
<html>
<jsp:useBean id="wikipage" scope="request"
class="net.amadan.xwiki.WikiPage" />
<head><title><%= wikipage.getTitle() %></title></head>
<body bgcolor="#ffffff">
<%@ include file="page-header.jsp" %>
<%= wikipage.asHtml() %>
<%@ include file="page-footer.jsp" %>
</body>
</html>

It's usually possible to get code out of jsp with refactoring and
into beans or taglibs. Here's an example of a wiki search page that
needs some work to get the form methods factored out:

<jsp:useBean id="wikipage" scope="request"
class="net.amadan.xwiki.WikiPage" />
<jsp:useBean id="wikiquery" scope="request"
class="net.amadan.xwiki.WikiPage" />
<html>
<head><title><%= wikipage.getTitle() %></title></head>
<body bgcolor="#ffffff">
<%@ include file="page-header.jsp" %>
search for page:
<form method="POST" action="<%=
response.encodeURL("wiki?Search") %>">
<input type="text" size="40" name="searchFor" value="<%=
wikiquery.getTitle() %>"/>
<input type="submit" value="go">
</form>
<p>
search in pages:
<form method="POST" action="<%=
response.encodeURL("wiki?Search") %>">
<input type="text" size="40" name="searchIn" value="<%=
wikiquery.getTitle() %>"/>
<input type="submit" value="go">
</form>
<hr>
<%= wikipage.asHtml() %>
<br/>
<%@ include file="page-footer.jsp" %>
</body>
</html>


here's one for an index page that needs a for loop taken out (that
has the benefit of removing the <%@ noise at the top):


<%@ page contentType='text/html; charset=UTF-8' %>
<%@ page language="java" %>
<%@ page import="java.util.List" %>
<jsp:useBean id="results" scope="request" class="java.util.List" />
<html>
<head><title>WikiIndex:</title></head>
<body bgcolor="#ffffff">
<p><br>
WikiIndex:
<br> <hr>
<ul>
<% for(int i=0; i<results.size(); ++i) { %>
<li/><a href="wiki?<%= results.get(i) %>"><%= results.get(i)
%></a>
<% } %>
</ul>
<p><br>
<%@ include file="page-footer.jsp" %>
</body>
</html>


Overall I'd say these need more work to protect page designers (my
notion of maintainable here means page designers can change visual
stuff without breaking the app or going thru a programmer, or can
request code behaviour changes easily). The hardest bits to tease
apart are usually dynamically generated tables and lists. I also
think if we had a way of thinking about managing web apps other
than files, life would be easier.

Bill de hÓra
-----Original Message-----
We have tried both. Templates definitely work but then you
can't take advantage of things like JSP tags, specially the
Taglibs project in Jakarta or the tag libs in Struts.
On the other hand, we found it is possible to use JSPs, but
* call the servlet (application) first and only use the JSPs
for display.
* avoid calling data retrieval, or transactional stuff directly
from the JSPs, instead put results in a model.
* never embed Java code in the JSP, instead always use helper
methods in a renderer or utility class
* if you use a JSP tag, follow the rule above
* use nested tags for advertising more complex visual components
* avoid Javascript whenever possible (applies to
templates as well)
* use a framework that introspects inputs like our EAN
(enterprise
agent network), or Struts, etc.
* avoid putting things in the session, use the "request" scope
to pass the model whenever possible to the JSP
* in most app servers, there are options to cache JSPs, use them
include ...>
directive. This will ensure pre-compiled JSP pages instead
of individual runtime renderings for each JSP
* etc.
If you follow the rules above, JSPs become simply rendering
code that is more or less manageable,
- Mike
http://www.hipaaccelerator.com
http://www.e-architects.com
http://www.xbreed.net
-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.4

iQA/AwUBPKNXduaWiFwg2CH4EQK9FwCgw5BIbKFdB/ZXRwlDImOUGVn6TrUAoIKi
g7Pvo6a6Jvlq8WZRDJLnCTrW
=OmGS
-----END PGP SIGNATURE-----


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Mike Beedle
2002-03-28 20:03:18 UTC
Permalink
Post by Bill de hÓra
Here's a jsp WikiPage template that might make Mike's best
<html>
<jsp:useBean id="wikipage" scope="request"
class="net.amadan.xwiki.WikiPage" />
<head><title><%= wikipage.getTitle() %></title></head>
<body bgcolor="#ffffff">
<%= wikipage.asHtml() %>
</body>
</html>
Good examples.

In addition, I would add:

- use a common CSS (cascading style sheet), usually
included in wrapper JSP (your example above)

- make use of the CSS styles within tags that
paint HTML stuff (tables, inputs, etc.)

- make sure you only have _one_ form in every page,
because HTTP cannot submit multiple forms and otherwise
you would loose the contents of non-submitted forms. (While
it is possible to remember the contents of multiple
forms through introspection, you don't want to go there ;-)


- Mike
http://www.hipaaccelerator.com
http://www.e-architects.com
http://www.xbreed.net


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Bill de hÓra
2002-03-28 21:11:32 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-----Original Message-----
- use a common CSS (cascading style sheet), usually
included in wrapper JSP (your example above)
- make use of the CSS styles within tags that
paint HTML stuff (tables, inputs, etc.)
Yes (but avoid cascading the sheets unless you really need it!).

Bill de hÓra

-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.4

iQA/AwUBPKOG5+aWiFwg2CH4EQJNGACfeQFAHzN1viZKPuXgdjyHKorBJssAniTz
byKN28jrDc1qjpVgOprb67jC
=GwaE
-----END PGP SIGNATURE-----


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Mike Beedle
2002-03-29 04:14:22 UTC
Permalink
Post by Bill de hÓra
-----Original Message-----
- use a common CSS (cascading style sheet), usually
included in wrapper JSP (your example above)
- make use of the CSS styles within tags that
paint HTML stuff (tables, inputs, etc.)
Yes (but avoid cascading the sheets unless you really need it!).
Bill:

Yes, I agree. It is strange that just about everyone that
uses CSS avoids using the "cascading sheets" feature :-)

- Mike
http://www.hipaaccelerator.com
http://www.e-architects.com
http://www.xbreed.net


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Jonas Bengtsson
2002-03-28 20:56:25 UTC
Permalink
Post by Mike Beedle
We have tried both. Templates definitely work but then you can't
take advantage of things like JSP tags, specially the Taglibs project
in Jakarta or the tag libs in Struts.
What do you gain with jsp tag libs? I have never use jsp since I
thought servlets/templates was a neater solution (by templates I here
mean the Jakarta project Velocity). By looking at Bill de hÓra's
examples I can't see anything that isn't easily achieved in Velocity.

When talking about templates I must say that ZPT (Zope Page Template)
seems to be the best. It's the only template that I'm aware of that
maintains valid html/xml. However, it can only be used in Zope.

Best regards,
Jonas

Plans are worthless, but planning is essential
- Dwight D. Eisenhower


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Peter Hansen
2002-03-29 02:43:28 UTC
Permalink
Post by Jonas Bengtsson
When talking about templates I must say that ZPT (Zope Page Template)
seems to be the best. It's the only template that I'm aware of that
maintains valid html/xml. However, it can only be used in Zope.
Just a minor point: yes, it "can" be used only in Zope, but it
was deliberately designed to be usable in anything, so it "could"
be used with other languages and other web application servers.

It seems a very nice approach and it would be good to see the
concept moved outside of the Zope arena.

-Peter

To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Laurent Bossavit
2002-03-28 16:50:52 UTC
Permalink
Post by Jonas Bengtsson
Almost everyone recommends that one uses templates (e.g. Velocity for
servlets, ZPT for Zope) when developing web applications.
Almost everyone is entitled to his or her or its opinions, as I am to
mine. All I can do is tell what I think, what I do, what works for me. :)
Post by Jonas Bengtsson
Can't you unit testing by just mocking out the template-engine?
You can. There's e.g. Cactus in the Java world. I find that it works
best for me when I'm able to do very fine-grained testing, for
reasons which Kent is busy explaining these days. Mocking out the
template engine leads to expensive setups.


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Bill de hÓra
2002-03-28 17:16:35 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-----Original Message-----
Post by Jonas Bengtsson
Almost everyone recommends that one uses templates (e.g.
Velocity for
Post by Jonas Bengtsson
servlets, ZPT for Zope) when developing web applications.
Almost everyone is entitled to his or her or its opinions, as I
am to mine. All I can do is tell what I think, what I do, what
works for me. :)
Where almost everyone believes that dynamic page generation is a
good thing, then almost everyone believes in partitioning web work
into page designers, page programmers and maybe database
programmers.

While it may be easier to unittest markup in code, that does cause
page designers no end of grief. You might also want to avoid having
geeks of all flavours bumping into each other on the same file.
Possibly this is a limitation of using source code management tools
that are file-centric (such as cvs), or databases in a file-centric
way, rather than a limitation in workflow or task specialisation.
More learning needed.

Bill de hÓra

-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.4

iQA/AwUBPKNPPOaWiFwg2CH4EQLUzQCaAlsBlQF6Cz9ECwTVs7rRKhdFxp8AoIWj
V5Xzad76BeOBO6HgpJ4d4NOh
=HnQS
-----END PGP SIGNATURE-----


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Charlie Poole
2002-03-28 18:10:17 UTC
Permalink
Post by Bill de hÓra
-----Original Message-----
Post by Jonas Bengtsson
Almost everyone recommends that one uses templates (e.g.
Velocity for
Post by Jonas Bengtsson
servlets, ZPT for Zope) when developing web applications.
Almost everyone is entitled to his or her or its opinions, as I
am to mine. All I can do is tell what I think, what I do, what
works for me. :)
Where almost everyone believes that dynamic page generation is a
good thing, then almost everyone believes in partitioning web work
into page designers, page programmers and maybe database
programmers.
While it may be easier to unittest markup in code, that does cause
page designers no end of grief. You might also want to avoid having
geeks of all flavours bumping into each other on the same file.
Possibly this is a limitation of using source code management tools
that are file-centric (such as cvs), or databases in a file-centric
way, rather than a limitation in workflow or task specialisation.
More learning needed.
Agreed. Separation of these two parts is a good thing in most environments.
Templates sometimes make this hard but, as the saying goes, a level of
indirection can solve any problem.

I'd use code to set variables, create little html fragments in files,
etc. and then let the templates to include them.

I know nothing about Zope, however, so you'd have to figure out the
exact implementation of this approach.

Charlie Poole
***@pooleconsulting.com


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Jonas Bengtsson
2002-03-28 20:42:17 UTC
Permalink
Post by Laurent Bossavit
Almost everyone is entitled to his or her or its opinions, as I am to
mine. All I can do is tell what I think, what I do, what works for me. :)
I was not objecting to your opinion. I just pointed out that it
differs from what I perceive to be the "common opinion" :-)
Post by Laurent Bossavit
You can. There's e.g. Cactus in the Java world. I find that it works
best for me when I'm able to do very fine-grained testing, for
reasons which Kent is busy explaining these days. Mocking out the
template engine leads to expensive setups.
I was either unclear or misusing terms. What I meant was:

The servlet (or whatever) assigns data to a context object.
So for each feature you can retrieve the data from the context object
and check if it corresponds to the expected data.

Doing this should be very simple and not require any expensive setups.
One drawback is, however, that this approach wouldn't test the
rendering that the template performs.

However, my experiences in unit testing is limited, so don't take my
word for it. :-)

Best regards,
Jonas

Nobody goes there anymore; it's too crowded.
- Yogi Berra


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Laurent Bossavit
2002-03-28 08:51:19 UTC
Permalink
Post by Bill de hÓra
Post by Laurent Bossavit
I made a baaaaad mistake trying to implement a generic framework
for editing XML content, based on XML Schema definitions. This
thing never worked well.
Can you say more about this too?
I will, though it embarrasses me. All the more so as I bragged about
it in this very forum, before it turned out bad.

The user story was... wait, there wasn't even a user story. What the
users wanted was an easy way to type in a new piece of content,
like an article or a job offer or a book review or whatnot.

The rest of the content management framework takes care of
making all the content look good and uniform and professional once
it's published on the site, using magic technology such as XML and
XSL.

But to get to that point the content needs to be collected from the
authors and formatted as XML. Business problem : the authors are
people who don't know XML from Ecstasy. So they need a friendly
user interface to type in new content.

Okay, so that's where the clever, visionary, inspired, and above all
stupid coder in me took over. I figured if I could describe the XML
content by way of an XML Schema file, I could use the Schema to
generate a user interface for each and every type of content that
could ever be imagined, thus saving myself years of painful work
making the user interfaces "by hand".

So for instance, if I had a Schema file saying that an "article"
contained a Title and several Paragraphs, like this in pXML :

<type name="article">
<element name="title" occurrences="exactly one">
<element name="paragraph" occurrences="one or more">

I could read this and automatically generate a text field with a label
"title", followed by a textarea with a label "paragraph", and a lil'
button to add a new paragraph because I knew there could be more
than one, and...

You get the picture. It's probably a clever idea but by then I was
entirely too taken with it, and no longer doing the customer's stuff
but my own.

How I *should* have gone about it is left as an exercise to the
reader. As for myself, I hope I have learned that lesson for good. ;)


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Charlie Poole
2002-03-28 17:59:57 UTC
Permalink
Laurent,
Post by Laurent Bossavit
You get the picture. It's probably a clever idea but by then I was
entirely too taken with it, and no longer doing the customer's stuff
but my own.
Nice phrase. I suspect a few of us could get together and write a
book about all the times we did that!

Charlie Poole
***@pooleconsulting.com




To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Tim Moore
2002-03-28 17:32:51 UTC
Permalink
Yes, maybe I'm going out on a limb for this group, but ideally there is
little to no logic in your templates, which makes unit-testing them less
necessary. If your template is all static markup with one scriptlet in
it that calls an accessor on a bean (as in Laurent's example snippet)
then I'd argue that assuming the bean class is unit testing your
template couldn't possibly break, and for that reason doesn't need to be
testing. The same is true in ZPT, which strongly encourages putting
logic into python scripts.

Now if you have a lot of complex presentation logic, that may be another
story...and you do specifically say "complex pages". If there's more
code than markup, then a template doesn't make any sense, and it would
actually be better to go with Laurent's strategy of using embedded HTML
in code rather than the other way around. It all depends on the
complexity of the page logic I guess.
--
Tim Moore / Blackboard Inc. / Software Engineer
1899 L Street, NW / 5th Floor / Washington, DC 20036
Phone 202-463-4860 ext. 258 / Fax 202-463-4863
-----Original Message-----
Sent: Thursday, March 28, 2002 11:31 AM
To: XP-YahooGroups
Subject: Re: [XP] Unit testing Web pages
Post by Laurent Bossavit
Post by Paolo Bizzarri
In this scenario you seem to suggest that it could be a
better choice
Post by Laurent Bossavit
Post by Paolo Bizzarri
to move things from the templates directtly to the Python
scripts (or
Post by Laurent Bossavit
Post by Paolo Bizzarri
to extenrnal Python classes, that are always possible).
Yes, that's what I suggested. That's what I would try in Zope, if I
ever worked with it, and if I had to unit test code that generated
complex pages. Maybe it wouldn't work... Though I would be very,
very surprised if it didn't.
Laurent,
Almost everyone recommends that one uses templates (e.g. Velocity for
servlets, ZPT for Zope) when developing web applications. The main
reason seems to be maintainability.. Writing inline html output in
servlets leads to cluttered code. However, I have no experience unit
testing web apps.
In most template languages there is a context which all data is
req -> servlet -(assigns data)-> context <-(reads data)- template
res <-(renders)-/
Can't you unit testing by just mocking out the template-engine?
Best regards,
Jonas
When you come to a fork in the road, take it!
- Yogi Berra
ad-free courtesy of objectmentor.com
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
David Corbin
2002-03-28 18:02:37 UTC
Permalink
Post by Tim Moore
Yes, maybe I'm going out on a limb for this group, but ideally there is
little to no logic in your templates, which makes unit-testing them less
necessary. If your template is all static markup with one scriptlet in
it that calls an accessor on a bean (as in Laurent's example snippet)
then I'd argue that assuming the bean class is unit testing your
template couldn't possibly break, and for that reason doesn't need to be
testing. The same is true in ZPT, which strongly encourages putting
logic into python scripts.
Often, I write "UnitTests" for JSPs because they are compiled at
runtime. I want to know that if I refactor a java class, that I get all
the dependent pages correct, too. (I hate JSPs)

David


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Tim Moore
2002-03-28 17:45:13 UTC
Permalink
I pretty much agree with you, but there's one gotcha...
...>
Post by Mike Beedle
directive. This will ensure pre-compiled JSP pages instead
of individual runtime renderings for each JSP
You have to be careful with this for a couple of reasons. For one
thing, I've noticed that at least on Tomcat 3.3, if you change an
@included page, the container doesn't recognize this and regenerate the
servlet for any pages that include it. That's just a
development/testing gotcha. More importantly, the top-level page and
any included pages share a pageContext and local variable scope (unlike
with jsp:include) so you have to be careful about naming conflicts.
OTOH, with Tomcat 3.3 and any other JSP 1.1 containers, you aren't
allowed to use jsp:include from inside a BodyTag, so I end up usually
using the @include anyway.

Sorry if I've strayed too far off-topic :-)
--
Tim Moore / Blackboard Inc. / Software Engineer
1899 L Street, NW / 5th Floor / Washington, DC 20036
Phone 202-463-4860 ext. 258 / Fax 202-463-4863
Post by Mike Beedle
-----Original Message-----
Sent: Thursday, March 28, 2002 12:17 PM
Subject: RE: [XP] Unit testing Web pages
Post by Paolo Bizzarri
Post by Laurent Bossavit
Post by Paolo Bizzarri
In this scenario you seem to suggest that it could be a better
choice to move things from the templates directtly to the Python
scripts (or to extenrnal Python classes, that are always
possible).
Post by Paolo Bizzarri
Post by Laurent Bossavit
Yes, that's what I suggested. That's what I would try in
Zope, if I
Post by Paolo Bizzarri
Post by Laurent Bossavit
ever worked with it, and if I had to unit test code that
generated
Post by Paolo Bizzarri
Post by Laurent Bossavit
complex pages. Maybe it wouldn't work... Though I would be very,
very surprised if it didn't.
Laurent,
Almost everyone recommends that one uses templates (e.g.
Velocity for
Post by Paolo Bizzarri
servlets, ZPT for Zope) when developing web applications. The main
reason seems to be maintainability.. Writing inline html output in
servlets leads to cluttered code. However, I have no
experience unit
Post by Paolo Bizzarri
testing web apps. In most template languages there is a
context which
Post by Paolo Bizzarri
req -> servlet -(assigns data)-> context <-(reads data)- template
res <-(renders)-/
Can't you unit testing by just mocking out the template-engine?
We have tried both. Templates definitely work but then you
can't take advantage of things like JSP tags, specially the
Taglibs project in Jakarta or the tag libs in Struts.
On the other hand, we found it is possible to use JSPs, but
* call the servlet (application) first and only use the JSPs
for display.
* avoid calling data retrieval, or transactional stuff directly
from the JSPs, instead put results in a model.
* never embed Java code in the JSP, instead always use helper
methods in a renderer or utility class
* if you use a JSP tag, follow the rule above
* use nested tags for advertising more complex visual components
* avoid Javascript whenever possible (applies to
templates as well)
* use a framework that introspects inputs like our EAN
(enterprise
agent network), or Struts, etc.
* avoid putting things in the session, use the "request" scope
to pass the model whenever possible to the JSP
* in most app servers, there are options to cache JSPs, use them
include ...>
directive. This will ensure pre-compiled JSP pages instead
of individual runtime renderings for each JSP
* etc.
If you follow the rules above, JSPs become simply rendering
code that is more or less manageable,
- Mike
http://www.hipaaccelerator.com
http://www.e-architects.com
http://www.xbreed.net
ad-free courtesy of objectmentor.com
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Bill de hÓra
2002-03-28 17:59:09 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-----Original Message-----
I pretty much agree with you, but there's one gotcha...
...>
Post by Mike Beedle
directive. This will ensure pre-compiled JSP pages instead
of individual runtime renderings for each JSP
You have to be careful with this for a couple of reasons.
For one thing, I've noticed that at least on Tomcat 3.3, if
this and regenerate the servlet for any pages that include
it. That's just a development/testing gotcha.
Yuck. Would a scrip that called the admin servlet on deployment
help you there?
importantly, the top-level page and any included pages share
a pageContext and local variable scope (unlike with
jsp:include) so you have to be careful about naming
conflicts.
Following java package naming conventions can help protect you
here.

Bill de hÓra

-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.4

iQA/AwUBPKNZ6uaWiFwg2CH4EQKsgACeNjJueR9yM+BLJ1XuMWuQ0W1wrUYAn0gC
KW4ioCCyGkmmSbMX5RZZlGLs
=Ew+q
-----END PGP SIGNATURE-----


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Laurent Bossavit
2002-03-29 09:26:30 UTC
Permalink
Where almost everyone believes that dynamic page generation is a good
thing, then almost everyone believes in partitioning web work into page
designers, page programmers and maybe database programmers.
That sentence doesn't quite parse for me. Maybe I understand it
correctly, maybe I don't, so feel free to correct me.

I too think that dynamic page generation is a good thing. You would
have to be a fool to insist that ahead-of-time page generation (which
is what I think "dynamic" page generation is being opposed to) is an
appropriate solution in all cases; though people might be surprised
to see how simple, clean, fast and powerful ahead-of-time can be.

On the other hand, dynamic page generation does not seem to me
to imply, necessarily, page templating or template languages, à la
JSP, ASP, PHP and whatnot. What do you think ?

I am suggesting that JSP, ASP, PHP et al have drawbacks in some
circumstances. I have specific reasons to believe this (unit testing is
harder), and these reasons stand, it seems to me, regardless of
how many people thing templating is a good thing. What do you
think ?

I am also convinced that "partitioning Web work" has its drawbacks
in some circumstances. But this seems to me to be moving the
conversation in a different area entirely.
While it may be easier to unittest markup in code, that does cause
page designers no end of grief.
I'm open to finding ways of working that do not cause page
designers any amount of grief. I prefer not to cause grief, if that can
be avoided. If I can't avoid it... I can't.

I am confident that I could find ways of working that do not cause
grief to anyone and still permit unit testing page generation code at a
fine-grained level, if I was working in that kind of team. Right now
I'm no longer working in the Web sector, though.

Mike Beedle posted further concrete advice for working with JSP
pages. If you're keen on doing JSP, I suggest listening to him, it's
good advice.

If you're keen on doing programs that work with a process that
works, take advice where you can but *above all* don't take "almost
everyone's" word for it about anything, and be open to the reality of
*your* project, *your* team, *your* management.


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Bill de hÓra
2002-03-29 11:03:18 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-----Original Message-----
I too think that dynamic page generation is a good thing. You
would have to be a fool to insist that ahead-of-time page
generation (which is what I think "dynamic" page generation is
being opposed to) is an appropriate solution in all cases;
though people might be surprised to see how simple, clean, fast
and powerful ahead-of-time can be.
I think it's good as well but I've seen it overdone.
On the other hand, dynamic page generation does not seem to me
to imply, necessarily, page templating or template languages, à
la JSP, ASP, PHP and whatnot. What do you think ?
Agreed, for examples, the web site I'm putting together for myself
at the moment is put together using a few python cgi scripts and a
front controller.
I am suggesting that JSP, ASP, PHP et al have drawbacks in some
circumstances. I have specific reasons to believe this (unit
testing is
harder), and these reasons stand, it seems to me, regardless of
how many people thing templating is a good thing. What do you
think ?
I am also convinced that "partitioning Web work" has its
drawbacks in some circumstances. But this seems to me to be
moving the
conversation in a different area entirely.
Sort of. But this is the driver for many of these template
langugaes especially the 'corporate grade' ones like JSP and ASP.
It's good to understand why anyone would bother inventing a new
syntax, rather than evolving an old one.
Mike Beedle posted further concrete advice for working with JSP
pages. If you're keen on doing JSP, I suggest listening to him,
it's good advice.
So good I posted corresponding examples to back up his advice.
If you're keen on doing programs that work with a process that
works, take advice where you can but *above all* don't take
"almost everyone's" word for it about anything, and be open to
the reality of *your* project, *your* team, *your* management.
Don't worry, I'm speaking from direct experience, direct
observation, direct standards involvement. (I only spew spurious
generalizations where they can't be archived ;).

Bill de hÓra

-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.4

iQA/AwUBPKRJ8+aWiFwg2CH4EQIlEgCeNKZw8cmkfUr1AYuGyesnfkmYZAkAoINS
DPDkQaD/W+gSt+g0dzkRumKx
=WjV3
-----END PGP SIGNATURE-----


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Laurent Bossavit
2002-03-29 11:33:18 UTC
Permalink
Post by Bill de hÓra
I am also convinced that "partitioning Web work" has its drawbacks in
some circumstances. But this seems to me to be moving the conversation
in a different area entirely.
Sort of. But this is the driver for many of these template
langugaes especially the 'corporate grade' ones like JSP and ASP.
Ah. Are you by any chance saying that some "preferred" way of
organizing the work of Web teams has been allowed to influence the
architecture of specific technologies ?

I assume this is what you are saying. Under this assumption, there
is one circumstance under which it seems to me that avoiding JSP
will make sense : when the team under consideration has a different
idea of how their work should be organized. Does this reasoning
strike you as sound ?

If you agree to the stipulation and the reasoning, wouldn't you also
agree that enterprises "under the influence" of XP are very likely to
have a different idea of team organization than others ?

If you agree with these stipulations (and you are welcome to differ,
this conversation is both stimulating and insight-laden), would you
not, finally, agree with the conclusion that XP teams will want to be
wary of technologies like JSP ?
Post by Bill de hÓra
It's good to understand why anyone would bother inventing a new
syntax, rather than evolving an old one.
I wouldn't call JSP "old". I wouldn't call my 3- and 6- years old kids
"old", either. Does either strike you as unreasonable ?


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Bill de hÓra
2002-03-31 08:24:14 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-----Original Message-----
Ah. Are you by any chance saying that some "preferred" way of
organizing the work of Web teams has been allowed to influence
the architecture of specific technologies ?
I think it's possible. I also think it's possible to get my cause
and effect backways, so I'm wary of coming off the fence on that
one.
I assume this is what you are saying. Under this assumption,
there is one circumstance under which it seems to me that
avoiding JSP will make sense : when the team under consideration
has a different idea of how their work should be organized. Does
this reasoning strike you as sound ?
Yes. But I'd like to try and qualify it: the thing with building
web sites is that it often requires the input of different parts of
the organisation as it is built (as opposed to at requirements),
web sites often serve multiple business and political purposes
within the organisation. Setups where the designers, content folk
and page builders were in-housed in the marketing department, while
the programmers were Somewhere Else or outside the organisation
entire (sometimes the designers also) are common enough. It's very
difficult sometimes to coordinate the organisation around the
project. You could say that too many customers spoil the code.
If you agree to the stipulation and the reasoning, wouldn't you
also agree that enterprises "under the influence" of XP are very
likely to have a different idea of team organization than others
?
Yes, but I understand the relationship between XP and
interaction/usability design to be an open issue. Interaction
designers like to see somewhat more upfront design than is found in
XP. I'm not aware of a compelling argument from either discipline,
but my bias these days is towards less design.

Having trained as a product designer and worked with highly
architected software until recently, I claim these as working
truths:

o Architecture requires the character of physical law.
o The character of physical law is not assured in software.
If you agree with these stipulations (and you are welcome to
differ, this conversation is both stimulating and
insight-laden), would you not, finally, agree with the
conclusion that XP teams will want to be wary of technologies
like JSP ?
Extremely wary; pun intended. We know it threatens test first (imo
test first is the bedrock of XP). Unit testing a client server app
makes XP awkward, some for agent systems, and concurrency, but
sometimes they have real value and should be used. I'm glad you see
that computer languages are just technologies tho'.

I think the perceived value of languages like JSP is that it
enables the non-programmers to work with the web in a more powerful
way. But as you say, programmers may pay a price in productivity.
I'd hate to admit that there is a law of conservation of
productivity, and I care a lot about the web for some reason, so
figuring out how to let everyone play at their best is important to
me. Ideally it's the visicalc effect that falls out of this rather
than pass the parcel.

On the positive I do believe that agile methods can lead you
towards a proper separation of concerns (for example I think XP
would move you to discover Mike Beedle's best practices). If you're
going to build a web site that spans organisational concerns and
requires the input of non-programmers, or routing 'content
maintenance' around programmers, XP has value.

Bill de hÓra
Post by Bill de hÓra
It's good to understand why anyone would bother inventing a new
syntax, rather than evolving an old one.
I wouldn't call JSP "old". I wouldn't call my 3- and 6- years
old kids
"old", either. Does either strike you as unreasonable ?
(I was talking about the invention of JSP syntax itself.)



-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.4

iQA/AwUBPKYTiOaWiFwg2CH4EQJTBwCfajNpcpFtuFlGbGTIxxfaQ/AYciwAoPto
03q3lPGqhnvuZ72W099h4wCn
=ajh1
-----END PGP SIGNATURE-----


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Laurent Bossavit
2002-03-29 09:26:30 UTC
Permalink
In order to help learn/teach XPath, I wrote XPath Explorer. Please take
a look at http://www.purpletech.com/xpe and let me know if it's useful,
or could be useful. It'd be neat if we could collaborate on designing a
Web testing framework, or just some tools, based on XPath.
This looks *way* cool on rapid examination. Thanks for sharing this,
Alex. I'll play with it as other occupations permit and report any
findings.


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Loading...