jeudi 27 août 2015

How to organize test cases for a class with many methods?

The application that I'm working on does three things for every input (a unique id)

  1. Extract information from multiple source pertaining to that id
  2. Validate the information that I extract

    2.1 If the validation succeeds then go on to the next extraction

    2.2 If the validation fails, then do the first step for the next id

  3. After extraction is done from all the service, I get all the information, transform and form the value object

For Extraction, I have created a class for every service I'm hitting and getting the information.

I access the object of the extract classes in the transformation and perform the transformation.

My transformation class looks something like this:

        builder
        .field1(getField1(extract1))
        .field2(getFiedl2(extract1, extract2))
        .field3(getField3(extract3))
        ....
        .field100+(getField(extract..))
    return builder;

Now, I want to write test cases for the transformation I am doing. I am having trouble in organizing the test cases.

If I create a class for every method, then I would end up in more that 100 classes. Also If I take the approach of 1 test class per class then I would be writing all the test cases in one class and it would become really hard to understand.

Could anyone suggest what should be done?

Aucun commentaire:

Enregistrer un commentaire