dezone

Just another dezone weblog

TestedBy

Un’interessante idea di Stefano a proposito dei test. Cambiare il punto di vista: dal test che verifica il comportamento di una o più classi, alla classe a cui sono collegati dei test che verificano il comportamento della stessa e stabiliscono un contratto, cioè esplicitando comportamenti che poi vengono documentati, anche nel javadoc.

public class TestedBySample {

    /**
     * @param args
     */
    public static void main( String[] args ) {
        TestedBySample sample = new TestedBySample();
        System.out.print(sample.add(1, 2));

    }

    @TestedBy( testClass = "it.javalinux.testedby.TestedBySampleTest", testMethod = "addShouldWork" )
    public int add( int i,
                    int j ) {
        return i + j;
    }
 @TestedByList( {@TestedBy( testClass = "it.javalinux.testedby.TestedBySampleTest", testMethod = "addShouldWork" ),
        @TestedBy( testClass = "it.javalinux.testedby.TestedBySampleTest", testMethod = "addShouldWork2" )} )
    public int add2( int i,
                     int j ) {
        return i + j;
    }

Il link del progetto è: http://code.google.com/p/testedby/

8 settembre, 2008 - Pubblicato da fdigiuseppe | java, sviluppo | , , , | Ancora nessun commento.

Non c'è ancora nessun commento.

Lascia un commento