Hi,

since too long time I talk from the benefits of better using Ant, in particular the UnknownElement. I've started this refactoring since a few months but still didn't find time to finish it. It's mostly done but to respect WebTest quality it has to generate EXACTLY the same report for the same selftests or the changes have to be intentional. This is not currently fully the case. To allow other committers to help finishing the work, I've committed the current state of my work and explain here a bit what it's all about.

** Big picture **
WebTest "configured" its nested steps at the time Ant added them to
<webtest> (the mayBeConfigured call). This is not the normal/best way to process (at least since ant 1.6) and has many consequences (properties evaluated to early, all steps held in memory, ...).
The normal way to process would be to avoid forcing instantiation of the
tasks. When Ant parses a <something someAttr=".."/> it first creates an
UnknownElement holding the information found in the xml file. When this
UnknownElement gets executed, it looks for the "something" task to
instantiate, configures it, execute it and releases it. This is what WebTest should do/allow.

** Main changes **
- mayBeConfigured is not called on tasks when they are added to a
container. A container sees only Tasks and not Steps (except for Filters
where I haven't succeeded to perform the changes)
- the information for the report is captured through a BuildListener
(required as the instances of the Steps are not accessible anymore, as they are wrapped in their UnknownElement)
- property expansion is performed through a custom PropertyHelper


** Consequences **
- ${} properties are evaluated just in time before task execution
- memory consumption should be really smaller, particularly for long
<webtest> as tasks are made available for garbage collection as soon as
they have been executed. Only the execution result is conserved.
- #{} properties get evaluated in nested non webtest tasks too


** Side effects (not yet used/checked) **
- task do not have to expand properties in their parameters anymore and
setters should have as parameters the type they really expect (ie
String, int, boolean, File, ...) instead of String.
Caution: this may have consequence for setters with File argument as ant
will resolve the path (according to its rules using the project's base
attribute value and so on) and not WebTest anymore. As this change make
WebTest behave more "Ant correctly" this is interesting but should be
documented.
- if we want we could allow nested properties evaluation like
${myProp.#{count}}. On the one side it may become difficult to read. On
the other side this is a real requirement that can currently only be
filled with a script step (what is even less readable)
- sleep step could be removed (Ant's sleep task is fully ok)
- AntWrapper could be deprecated and link to group
- current bugs with properties expansion in conjunction with macros will
probably be solved
- easier to dynamically add steps within execution sequence (for
instance recurrent checks)
- no need for the *.attributes resource files
- Step class doesn't need to hold execution time, status, ...
- possible to upgrade to Groovy 1.0-JSR-06
- ...

** Status **
I've tried many times to break these changes into small blocks but
failed and had to cope with a large rework of nearly the whole WebTest
code base. As it is "only" a refactoring, the goal was (and still is) to use the same selftests and to produce the same report.
The resources/build dir contains 2 new data to help controlling this:
- WebTestReport.reference.xml: a "normalized" report from the selftests generated with build 1397 (the latest before my commit) - cleanWebTestReport.groovy: a script allowing to "normalize" the selftest report Ex: groovy -n cleanReports.groovy < $workDir/WebTestReport.xml > $workDir/WebTestReport_new.cleaned.xml This allows to use a diff tool to compare the reference with the current status to see what still need to be done. This should probably be integrated into the build (after improvement) to avoid regression like the one I once cause for the AntWrapper).

I've changed the download page to indicate that current snapshot is not ready for use and refered to release 2.1.

Already too much written. Just ask for what I've missed ;-)

Jira ticket is WT-232
http://webtest-community.canoo.com/jira/browse/WT-232

Marc.

_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to