1 Reply Latest reply on Dec 7, 2009 8:28 PM by xsa lefter

    Seam Unit Testing using TestNG

    Lavanya k Newbie

      I have seam application for which I have to test a persist operation in one of the session bean class through unit testing.

      The approaches mentioned at -

      1. http://docs.jboss.org/seam/2.0.1.CR1/reference/en/html/testing.html

      provide information on how to do unit testing. But this is not working for me.

      Please let me know if it worked for anyone.

      Can anyone highlight any other simpler approach to perform this basic unit test in Seam.

        • 1. Re: Seam Unit Testing using TestNG
          xsa lefter Newbie

          Can you describe more about this is not working for me. ?

          For unit test, I'm follow some instruction from the reference book, and run well:

          public class EntityClassesTest extends SeamTest {
               // ... some code to initialize data... //
          @Test public void testCategoryEntity() {
               // Get the third data from sample list.
               Category c3 = this.sampleCategories().get(2); 
                    // Test for the original data.
               assert c3.getId().equals(3L);
               assert c3.getName().equals("Third Category");
               assert c3.getDescription().equals("Third Category Description");
               // change some original data
               c3.setName("Thirty Category");
               c3.setDescription("Thirty Category Description");
               // Test original data has been changed (using "not" semantics)
               assert !c3.getId().equals(3L);
               assert !c3.getName().equals("Third Category");
               assert !c3.getDescription().equals("Third Category Description");
               // Test changed data
               assert c3.getId() == 10L;
               assert c3.getName().equals("Thirty Category");
               assert c3.getDescription().equals("Thirty Category Description");

          And for the testng configuration xml:

          <!-- EntityClassesTest.xml -->
          <!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
          <suite name="Simple Sales Test Suite" verbose="2" parallel="false">
             <test name="EntityClassesTest - Test all entity classes.">
                 <class name="com.xl.simplesales.test.unit.EntityClassesTest" />

          But, yes, for component/integration test I have some problem described here.