couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: Small changes to jquery.couch.js ajax method for better testing?
Date Tue, 30 Mar 2010 00:28:26 GMT
On Mon, Mar 29, 2010 at 7:40 PM, Lena Herrmann <lena@zeromail.org> wrote:
> Hi,
>
> I think it is very bad style when you change code only in order to make it
> more testable. But I can't think of a way to test some methods without these
> small changes to jquery.couch.js:
>
> http://gist.github.com/348527
>
> Look at lines 33-35 and 37. Examples why the changes are needed are here:
>
> http://github.com/lenalena/couchdb/blob/testsuite/share/www/spec/jquery_couch_js_class_methods_spec.js#L38-47
>
> http://github.com/lenalena/couchdb/blob/testsuite/share/www/spec/jquery_couch_js_instance_methods_1_spec.js#L69-71
>
> The problem is that the details of the ajax request are encapsulated, which
> is a good thing. Whenever possible I try to test the results of the method
> and not its internals. But some methods only trigger something on couchdb,
> and it's hard or impossible to check the results (compact or cleanup view,
> for example).
>
> 1) Does someone have a better idea how to test the stuff, or
>
> 2) are these changes acceptable, or
>
> 3) are they not and the code should better stay untested?
>
> What do you think?
>
> Lena
>
>

If you're worried about changing production code for the sake of
testability, you may consider just monkey patching things for the
test. Granted I reckon in this case the real thing to be testing isn't
the simple function itself, but rather a browser's adherence to
expected AJAX operations.

In other news, the BSG references are quite amusing.

Mime
View raw message