[TIP] Talking to a test-is-from-outer-space crowd

Alfredo Deza alfredodeza at gmail.com
Wed Apr 13 05:35:57 PDT 2011


On Tue, Apr 12, 2011 at 10:34 AM, Mark Sienkiewicz <sienkiew at stsci.edu>wrote:

> Alfredo Deza wrote:
>
>>
>> But programming is hard too. So it shouldn't matter that UnitTest *might*
>> be difficult to grasp. If you want to get better
>> you might as well get used to learning things that are not easy to
>> understand at first.
>>
>
> I mostly agree, but not with this part.  You can't teach people by throwing
> all the complexity at them at once.  If you want to make a beginner try to
> avoid testing whenever possible, force them to concentrate on the mechanics
> of using unittest instead of the benefits of testing.
>

This was a personal opinion, not something that I mentioned in my talk. You
are right though; you can't teach people by giving them all the
complexity at once, however... you are assuming that this crowd (and maybe
others?) have the luxury of learning from someone else.

Not a single University teaches Python (in Peru, where I gave the talk) and
most of the graduate students have to pick it up by themselves to
cope with the Python developer demand. If you are self-taught and start
searching for "Python testing" in any popular search engine you can verify
that almost all the results talk about unittest.TestCase and show how to
implement tests with classes and inheritance.

I was able to get *one* result that returned something about doctests. None
talk about how to use assert in a test function and run some tests.



>
> For a beginner, you want a simplified system.  Did you ever study
> introductory physics or calculus and solve the problem where you drop a ball
> from a certain height and find when it hits the ground?  The problem is
> always "neglecting air resistance" because dynamic friction makes the
> problem too complicated for a beginner.
>
> But how can we make tests simple enough for a beginner?  Consider this test
> that works in nose:
>
>   def test_1() :
>      x = add(1,1)
>      assert x == 2
>
> A beginning programmer can understand this.  They don't need to think about
> "fixtures" or "suites" or "test cases" or "runners" or even how object
> inheritance works.  You can start teaching somebody to program in python,
> and on the first day they can write tests for their very first program.
>

Absolutely, just as long as someone experienced is teaching a beginner. This
would probably be the way I would approach teaching it to someone new.

>
> Someday, when they become more experienced, maybe you can show them a
> benefit to unittest.  But when that day comes, you don't have to persuade
> them that testing is a good idea -- they will already know that.  Instead,
> you can concentrate on the question at hand:  Why should I use unittest?
>  What does it do for me that I can't do more easily in some other way?  How
> does this complicated thing work?
>
> Nobody ever tries to present a "steep learning curve" as an advantage,
> because we know systems like that are hard to use and people want to avoid
> using them.  People find new material much more accessible if you structure
> it as a series of smaller steps.
>

This just doesn't happen in self-learning.

>
> Mark S.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20110413/e6b194a1/attachment.html>


More information about the testing-in-python mailing list