8 Replies Latest reply on Nov 28, 2007 8:52 AM by djfjboss

    Unit Testing With TestNG

    djfjboss Newbie

      When I try to test my (simple) application using TestNG, variables that are automatically bijected when running outside of the test environment (such as instances of EntityManager, FacesMessages and Log) are no longer created automatically.

      EntityManager can be fixed via:

      EntityManagerFactory emf = Persistence.createEntityManagerFactory("proj3");
       emf.createEntityManager();
       EntityManager em = emf.createEntityManager();
       setField(action, "entityManager", em);


      Log can be fixed via:
      setField(action, "log", LogFactory.getLog(DummyTest.class));


      But trying to fix FacesMessages via:
      setField(action, "facesMessages", FacesMessages.instance());

      results in an IllegalStateException, stating that there is no active conversation context.

      What is the correct way to deal with such issues?