Envelope/Quill DoesSunTestServlets

- Last edited September 9, 1999
All you want to do in your test code, is call the doGet method! However to do this directly you need an HttpServletRequest?, and an HttpServletResponse?. The interfaces for these objects are quite large and they also encompasse objects with yet more interfaces, namely the ServletOutputStream?.

When you see this, you start to ask yourself how Sun tests their Servlets in a simple repeatable manner, when there is all this baggage that you have to implement even for the simplest HelloWorld? servlet?

It should be easy for me to write:

 HttpServletRequest? r = new MockServletRequest?().
 r.addParamater("name","Tim");

MockOutPutStream? out = new MockOutputStream?(); HttpServletResponse? s = new MockServletResponse?(out);
myServelet.doGet(r,s);
assert(out.toString().indexOf(TEST_RESULT) > -1);
I haven't encountered any examples of this level of test, however maybe someone can prove me wrong!

In the meantime, Oli, Paul and I have been working around these difficulties to write useful tests. Some of this you can see in the RealCode, however there is more to come -- TimM


- Last edited September 9, 1999

https://casino-brain.com/