Where did you learn to unit test? How did you learn?

laotseu bdesth at removethis.free.fr
Wed Apr 30 19:14:35 EDT 2003


Sean 'Shaleh' Perry wrote:
> On Tuesday 29 April 2003 07:38, Christopher Blunck wrote:
> 
>>Hi all-
>>
>>This is my second generic question posted to c.l.p (the first was 'How
>>many of you are Extreme Programmers?') but it seems like a somewhat
>>appropriate discussion for the group.
>>
>>I've noticed in my development that Python programmers (in general)
>>write more unit tests than their java counterparts.  If I download a
>>project off of jakarta.apache.org, it very rarely has unit tests.
>>However, when I download a python module, it frequently has unit
>>tests.
>>
> 
> 
> I believe this is due in part to Python being an interpreted language.  With 
> Java you have a compiler thereto catch many problems but with Python most
> bugs, misfeatures, etc. can only be found by exercising the code. 

Java has the same mixture of compilation/interpretation than Python. The 
only differences are that :
- the python runtime (== VM) byte-compile the source code by itself if 
necessary,
- Python has dynamic typing where Java has static typing

So with Java you have to manually call the compiler, which may refuse to 
compile because an object is not *declared* to implement a given 
interface even if it does. And that's the only 'bug' (may be one, may be 
not) the Java compiler may find for you.

In both cases, you *need* unit test to catch *real* bugs.

> Python 
> coding is all about handling the runtime which makes for rapid writing of 
> code but almost requires stronger testing.

Ok for one point : a given object does not implement the interface it 
should. The Java compilers ensure the interface is *formally* 
implemented (which, IMHO, doesn't buy you that much).

(snip the rest)

Laotseu





More information about the Python-list mailing list