directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tencé, Vincent" <>
Subject Tests naming
Date Wed, 16 Mar 2005 17:34:40 GMT
I started looking at removing Snacc dep in asn1/ber and came accross this
test I have to change. But I have no clue what it is doing:

    public void testAbandonMessage() throws Exception
        AbandonRequestImpl request = new AbandonRequestImpl( 1 ) ;
        request.setAbandoned( 3 ) ;
        decode( request ) ;
        roundTripTest( request ) ;
        assertFalse( tlvList.isEmpty() ) ;

I'll take the opportunity to discuss test methods naming. The issue with
this sort of naming is that it doesn't help if you don't know the code - I
hope it's clear at least to someone who knows the code ;-) - so you lose a
the power of test as a documentation mechanism. Basically I'm stuck, not
knowing what the code does nor what the test is trying to prove.

The approach I favor is to name test methods so that they describe the
intention of the test, rather than the method or the data under test. For
example, if I'm writing a test for a decorator that caches compiled java
classes from script, instead of writing tests like:


I would favor:


I have found that this practise helps a lot in documenting tests and code,
for others as well as yourself when you're reading your tests later on. It
also helps clarify what you're trying to achieve when you're writing the
test. It keeps you focused and helps think of other test cases you're not

I'd like to hear what you guys have to say on this, and discuss the adoption
of such a practise for the project. When we're at it, I'd like to open a
discussion on the testing practices we want to enforce.

-- Vincent

> -----Original Message-----
> From: Alex Karasulu []
> Sent: March 16, 2005 1:05 AM
> To: Apache Directory Developers List
> Subject: Re: [asn1] Why do we still have a snacc4j dep in ber project?
> Vincent Tence wrote:
> >I removed Snacc4j dep from ldap-provider. I didn't know we had other
> >subprojects dependent on Snacc. I'll take a look at the ber 
> suproject.
> >Any other suspect I should investigate?
> >
> >  
> >
> That should be about it.  Thanks man!
> Once your done let me know and I'll retire the code.  Perhaps 
> we need a 
> retirement area as opposed to using a sandbox.  For some 
> stupid reason 
> that's what I had done with apseda.  I'll fix that later.
> Alex
> >-- Vincent
> >
> >On Wed, 2005-03-16 at 00:14 -0500, Alex Karasulu wrote:
> >  
> >
> >>Hey Vince,
> >>
> >>I thought you wacked this.  I tried blowning away the 
> snacc4j stuff but 
> >>it made tests fail.  Am I loosing my mind?
> >>
> >>Alex
> >>    
> >>

View raw message