velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shinobu Kawai <shinobu.ka...@gmail.com>
Subject Testing Velocity with JUnit.
Date Tue, 09 Nov 2004 13:03:26 GMT
Hi all,

I'd like to share how I've been testing Velocity with JUnit lately.

First, I made a base TestCase class, AbstractVelocityTestCase.
  
http://sylow.no-ip.com/maven/site/ShinobuDemo/xref/org/ieee/shinobu/demo/velocity/AbstractVelocityTestCase.html
This class has the properties needed to test VTL:
- engine : The VelocityEngine to use for template processing.
- template : The VTL String to process.
- context : The Context to use when processing the template.
- expected : The expected result String.

After configuring these properties, I call assertVelocity(), which
will process the template and compare it with the expected result. 
PublicFieldUberspectTest shows an example of the general flow.
  http://sylow.no-ip.com/maven/site/ShinobuDemo/xref-test/org/apache/velocity/tools/generic/introspection/PublicFieldUberspectTest.html

Many other example tests can be found at:
  http://sylow.no-ip.com/maven/site/ShinobuDemo/xref-test/org/ieee/shinobu/demo/velocity/package-summary.html

For testing ViewTools, I have made AbstractVelocityMockStrutsTestCase
which uses strutstestcase.
  http://sylow.no-ip.com/maven/site/ShinobuDemo/xref/org/ieee/shinobu/demo/velocity/AbstractVelocityMockStrutsTestCase.html
cf. http://strutstestcase.sourceforge.net/
The flow of testing remains the same.

As always, any comments are welcome.  :)

Best regards,
-- Shinobu Kawai

-- 
Shinobu Kawai <shinobu.kawai@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message