0 Replies Latest reply on Feb 15, 2013 8:23 AM by sathiya seelan

    Test is getting executed multiples of number or rows returned by @Dataprovider (TestNG)and I'm using in container Mode

    sathiya seelan Newbie

      I'm using TestNG as Unit Test Framework and  Jboss AS7.1.1 Final as server

       

      The data provider  and Test methods works well in Client Mode

       

      The same dataprovider will return 10 rows and my Test method is getting executed nearly 100times in In container mode

       

      Test method :

       

         @Test(groups="bean-tests",dataProvider="Presenter-Data-Provider")

         public void findByIdPositiveTest(long presenterId,String expectedPresenterName)

         {

       

         }

       

      Dataprovider method:

       

         @DataProvider(name = "Presenter-Data-Provider")

          public  Object[][] presenterTestDataProvider()

          {

       

              EntityManagerFactory emf=null;

              EntityManager em=null;

              Object testcaseData[][]=null;

              Session session=null;

              try

              {

                  emf=Persistence.createEntityManagerFactory("TestCaseDataSource");

                  em=emf.createEntityManager();

                  session=em.unwrap(Session.class);

                  Criteria query=session.createCriteria(TestPresenter.class).setFirstResult(0).setMaxResults(10);

                  List<TestPresenter> rowList=query.list();

                  testcaseData=new Object[rowList.size()][2];

                  for(int loopCount=0;loopCount<rowList.size();loopCount++)

                  {

                      TestPresenter row=rowList.get(loopCount);

       

                      testcaseData[loopCount][0]=row.getPresenterId();

                      testcaseData[loopCount][1]=row.getExpectedPresenterName();

                  }

       

       

              }

              catch(Exception exception)

              {

                mLog.error(exception.getMessage()); 

              }

              return testcaseData;

       

          }

       

      I'm running as Test Suite using folowing Suite configuration

       

      <?xml version="1.0" encoding="UTF-8"?>

      <suite name="Development test suite">

       

          <test name="Bean testing">

              <groups>

                  <run>

                      <!-- This has to be added by default while using arquillian Test Runner -->

                      <include name="arquillian" />

                      <include name="bean-tests" />

                     

                  </run>

              </groups>

              <classes>

                  <class name="blah.blah.blah.PresenterManagerBeanTest" />

              </classes>

          </test>

      </suite>

      Pls let me know What I did was wrong

      Or direct me how to get values from DB  to Data provider and tests using In container mode

       

      Thanks in advance

       

      sathiya seelan