mercredi 27 juillet 2016

Understanding TestSuites

TestNG 6.8.8

I have the following interface:

public interface MyInterface{
    /**
    * Some contract
    **/
    public String convert(String arg);
}

Now I have a bunch of MyInterface implementations: MyInterface1Impl, MyInterface2Impl, MyInterface3Impl, etc...

The issue is that I want to test the general contract defined in JavaDoc as well as details of a specific implementation. An I'd write something like this:

public class MyInterfacecontractTestSuite{

    @Test(dataProvider="someDataProvider")
    public void testContract(MyInterface mi, String arg){
        //test
    }
}

and, for instance

public class MyInterface1ImplTest{
    //test cases for the implementation MyInterface1Impl
}

But it looks a little bit messy in that the cases for MyInterface1Impl are not all in the MyInterface1ImplTest class which might be confusing for a bit.

But putting a duplicate test case for the general contract in every implementation test class is weird as well.

So, I'm not qiute sure if I'm on the right way. Maybe there's some better solution for testing such contracts.

Aucun commentaire:

Enregistrer un commentaire