OK, forgive me for this - it's probably a hang-over from expectations I had
from using Spring.
Basically, we have two applications, the job of one is to provide control over
a several instances of the second, as well as managing a job queue which
updates the databases used by the second. Since we are using very long jobs, we
have a web service to service that looks after the job queue, which in a live
application will be running typically on a second server. Our task is to
provide some kind of round-trip tests of as much as we can without having our
testing framework script updates to live web servers. To cap it all, this is on
Windows. I'm trying to do as much of a system test as is possible without
actually installing, starting, and stopping Windows services.
What I wanted to be able to do was mock out the remote job queue web service,
so at least I could check out that the front end render stuff without to put an
entire web server temporarily in place. Basically, I'd hoped to replace the
model that implements the web service and check that the right stuff goes in
and out.
I managed to test the remoteness independently, by virtue of mocking
LWP::UserAgent and FCGI with some fakery. Moose seems to be helping; I had
already got an abstract class for the remoting system, but since that's better
as a role, this does seem to be something I can test with something that
replaces the web bridge.
You're right, of course, finer grained testing would probably be better at
picking up most of the issues. And I probably do need to do the whole system
test thing, and maybe I just need to confront Win32::Process and just spin up a
test web service for this. Not what I'd wanted, but probably the right thing to
do.
All the best
Stuart
On 2010-01-17, at 3:23 PM, Tomas Doran wrote:
>
> On 17 Jan 2010, at 18:36, Stuart Watt wrote:
>
>> On 2010-01-16, at 10:31 PM, Tomas Doran wrote:
>>
>>> I tend to just use Moose directly to construct mock classes for me:
>>
>> Things are improving, t0m. I tried
>>
>> use Class::MOP;
>> use Class::MOP::Class;
>> my $meta_refreshes = Class::MOP::Class->create('ARMAdmin::Model::Refreshes');
>> $meta_refreshes->add_method('get_profiles' => sub { die("Failed to get
>> profiles"); });
>>
>> Then I start the app in the test framework. I'm just after getting the
>> get_profiles mocked method called here, later I want it to return values I
>> can test in the generated page.
>>
>> However, Catalyst then calls:
>>
>> Catalyst::Utils::ensure_class_loaded( $component, { ignore_loaded => 1 } );
>
> Right, hang on.. Why are you mocking things and then loading the entire
> application?
>
> Usually you either run the full app for system testing (with test config that
> points at a test DB or whatever), or you mock _lots of stuff_ (like the
> context class, the request and response) and unit test one component..
>
> Trying to mangle methods then load the full app won't work..
>
> If you reaaaaalllly need to do this - use Catalyst::Test 'MyApp', then
> manipulate the class after catalyst has loaded it (e.g my $meta =
> MyApp::Model::Foo->meta; $meta->remove_method('bar'); $meta->add_method('bar'
> => sub { die("New bar") }); )
>
> but I'd not recommend it..
>
> Cheers
> t0m
>
> _______________________________________________
> List: [email protected]
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/[email protected]/
> Dev site: http://dev.catalyst.perl.org/
>
> --
> This message was scanned by ESVA and is believed to be clean.
> Click here to report this message as
> spam.http://antispam.infobal.com/cgi-bin/learn-msg.cgi?id=F27212807F.6322C
>
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/