2 Replies Latest reply on Mar 18, 2008 1:42 PM by Erik Slagter

    Conditional mocking

    Erik Slagter Newbie

      Hi Seam experts!


      I am writing tests for my framework I have written using Seam.
      I am allready using mocking for some of my test, which works fine!


      But now, I want to test the functionality of the real object.


      I have written two classes and a interface



      public interface IMyClass{
           public bar();
      }





      @Name("myClassName")
      public class MyClass implements IMyclass{
           public bar(){
                System.out.println("Using the real class");
           }
      }





      @Name("myClassName")
      @Install(precedence=Install.MOCK)
      public class MyClassMock implements IMyclass{
           public bar(){
                System.out.println("MOCKING");
           }
      }




      I instantiate my class using the following construction:


      MyClass myClass = (MyClass) Component.getInstance("myClassName");




      When I call myClass.bar(); the Mock object is called instead of the normal implementation.


      How can I keep using the MOCK object and use the normal object in a other test?