0 Replies Latest reply on Jul 25, 2013 8:34 AM by makidev

    Create JSFUnit Tests on a Separate Project

    makidev Newbie

      I created a TestProject using Getting Started 1.3. This is a separate project that I'd like to use to test the MainProject. I was to able to get the TestProject up and running so my question is how do I create tests for the views and methods of the MainProject?

       

      NetBeans 7.3, JSF 2.1, GlassFish Server 3

       

      I was able create a reference from the TestProject to the MainProject by:

      1. Right-clicking TestProject -> Properties -> Libraries -> Add JAR/Folder

      2. Added the classpath: MainProject/build/web/WEB-INF/classes

       

      I did the same for the XHTML pages.

       

      On the JSFUnitStartupTest(created through Getting Started 1.3) class, I added a testMethod and created a class instance.

       

       

      public void testMethod throws IOException {

           MainProjectController controller = new MainProjectController();

           int favoriteNumber = controller.getFavoriteNumber();

           assertEquals(50, favoriteNumber);

      }

       

      When I run this i get a java.lang.NoClassDefFoundError.

       

      Also, what value do I need to replace "/index.xhtml" so that it points to "/login.xhtml" on my MainProject

       

      JSFSession jsfSession = new JSFSession("/index.xhtml");

       

      I am not sure if this is the right way to create a reference to the MainProject from the TestProject. I just followed this on a tutorial using JUnit in Eclipse.