mercredi 14 septembre 2016

The Test class require the method from a concrete class to be static

The test class requires a method to be defined as static in the concrete class. But the concrete class implements a method from an interface.

The interface does not allow the implemented method to be static.

Interface:

public interface ArithmeticSkeleton {

    public int operation(int a, int b);

}

Concrete Class

public class Divide implements ArithmeticSkeleton{

    public int operation(int a, int b) {        
        return (a / b);
    }
}

jUnit test case:

public class ArithmeticSkeletontest {

    private ArithmeticSkeleton as;

    @Test
    public void testDivision() throws Exception {
        assertEquals("5", Divide.operation(10, 2));
    }

}

However, the Test code does not allow Divide.operation to be accessed.

Aucun commentaire:

Enregistrer un commentaire