开发者

Mocking up Apache session data for unit testing

开发者 https://www.devze.com 2023-04-10 18:08 出处:网络
I\'m working with a web application that, normally, runs in mod_perl under Apache.A co-worker and I are trying to do some unit testing.Are there any good tools or techniques out there for mocking-up s

I'm working with a web application that, normally, runs in mod_perl under Apache. A co-worker and I are trying to do some unit testing. Are there any good tools or techniques out there for mocking-up sessions and requests and the like that could help us 开发者_StackOverflow中文版exercise this code outside of the web server context?


If you're using mod_perl 1, there is Apache::FakeRequest which comes with mod_perl. It is not a complete mock of the request object, so you have to add some methods of your own. Even more if your code uses Apache::Request. Yet more for cookies and uploads. Mostly you're going to be spending a lot of time with Test::MockObject. Fortunately, the Apache object interfaces are pretty straight forward.

If at all possible, you should consider switching to a Plack based framework (Catalyst, Dancer, etc...) which provide far more robust testing and debugging facilities. If you're using mod_perl2, you're in luck! It's easy (relative to mod_perl 1) to wrap a mod_perl2 application with Plack. Plack::App::FakeApache does most of the work for you. Here is a discussion sketching out the various techniques and benefits.

0

精彩评论

暂无评论...
验证码 换一张
取 消