>From someone who's window to your code is your public API, a
refactoring should make no observable change.

So if you only test on the public API, but you test it thoroughly,
then your tests will ensure that this property holds.

Tests that delve into implementation details and private things, are
more brittle because they are affected by changes in implementation
details.

On Fri, Sep 10, 2010 at 14:16, alux <[email protected]> wrote:
> Hi James,
>
> thanks for your answer.
>
>> your tests should be testing your public interface
>
> Hhmmm.
> Well, I tend to disagree here. I sometimes like to have tests in place
> for things I want to refactor. To not inadvertently do something
> foolish.
>
> But I agree that this is not easily accomplishable.
>
> Greetings, alux
>
> On 10 Sep., 13:39, James Reeves <[email protected]> wrote:
>> On 10 September 2010 12:24, alux <[email protected]> wrote:
>>
>> > I always thought it to be good style to make helper functions only as
>> > visible as needed, e.g. by using letfn.
>>
>> > But when I want to test my code, I just dont see a way to access these
>> > local functions for tests.
>>
>> I don't believe you can. You could make them private functions, and
>> then test them by referring directly to their vars, e.g.
>>
>> (#'your.namespace/private-function ...)
>>
>> But in general, your tests should be testing your public interface,
>> not a specific implementation. Your tests shouldn't care what your
>> code does behind the scenes, so long as the publicly accessible
>> functions return the correct result.
>>
>> - James
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to