jeudi 24 novembre 2016

Test: How to verify that a method is called?

Many Mock frameworks has a feature to verify if a method is called or not. However most frameworks requires that the code follows dependency injection pattern.

The code that i'm trying to test does NOT uses dependency injection pattern, therefore a mock of the object can not be injected.

Code ex.:

public class TestMeClass{
   public void TransformMe() {}
}

 public abstract class SomeeClass{
   public SomeMethod(){
    CallMeMethod();
   }

   private void CallMeMethod() {
      TestMeClass testMeClass = new TestMeClass();
      testMeClass.TransformMe();
   }
}

How can I verify that TransformMe() is called?

Jon Skeet I need you.

Aucun commentaire:

Enregistrer un commentaire