mercredi 24 octobre 2018

How to test method wrapper by another method?

Let's imagine having class (written in Java-like pseudocode):

class MyClass {

    ...

    public List<Element> getElementsThatContains(String str) {
        return this.getElementsThatContains(new Set<String> { str });
    }

    public List<Element> getElementsThatContains(Set<String> strs) {

        ...

    }
}

First of all - I have getElementsThatContains(Set<String> strs) properly 100% covered.

How should I cover getElementsThatContains(String str):

  • Should I copy (almost) all the tests but with call to getElementsThatContains(String str)?
  • Should I just make one test method that check if results from first and second methods are same (with same incoming data)?
  • Should I refactor my code so I do not have such a situation? (If yes, how?)

Aucun commentaire:

Enregistrer un commentaire