Uploaded image for project: 'Arquillian'
  1. Arquillian
  2. ARQ-327

Tests called twice

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 1.0.0.Alpha4
    • Base Implementation
    • None
    • Hide

      unjar test project
      start JBoss AS6
      run mvn test

      Show
      unjar test project start JBoss AS6 run mvn test

    Description

      I have a simple bean and test class. testFoo will always be called an extra time with every test. When it wants to do testFoo it will call testFoo twice. When it wants to do testBar it will call testFoo and then testBar. Both result with failure in assertEquals(0, myFieldBean.getCounter())

      Full Maven project attached as a jar.

      public class MyBean {
      private int counter = 0;
      public int getCounter()

      { return counter++; }

      }

      @RunWith(Arquillian.class)
      public class FooBarTest
      {

      @Inject MyBean myFieldBean;

      public FooBarTest()

      { System.out.println("Called FooBarTest constructor"); }

      @Test @Inject
      public void testFoo(MyBean myBean)

      { System.out.println("Called testFoo"); System.out.println("myBean=" + myBean.toString()); System.out.println("myFieldBean=" + myFieldBean.toString()); Assert.assertEquals(0, myBean.getCounter()); Assert.assertEquals(0, myFieldBean.getCounter()); }

      @Test
      public void testBar()

      { System.out.println("Called testBar"); System.out.println("myFieldBean=" + myFieldBean.toString()); Assert.assertEquals(0, myFieldBean.getCounter()); }

      }

      Output is:
      16:42:44,892 INFO [STDOUT] Called FooBarTest constructor
      16:42:44,904 INFO [STDOUT] Called testFoo
      16:42:44,905 INFO [STDOUT] myBean=org.jboss.aqbug.MyBean@2a5772
      16:42:44,907 INFO [STDOUT] myFieldBean=org.jboss.aqbug.MyBean@1d3018e
      16:42:44,915 INFO [STDOUT] Called testFoo
      16:42:44,917 INFO [STDOUT] myBean=org.jboss.aqbug.MyBean@11821
      16:42:44,918 INFO [STDOUT] myFieldBean=org.jboss.aqbug.MyBean@1d3018e
      16:42:44,965 INFO [STDOUT] Called FooBarTest constructor
      16:42:44,974 INFO [STDOUT] Called testFoo
      16:42:44,977 INFO [STDOUT] myBean=org.jboss.aqbug.MyBean@12b4d3
      16:42:44,978 INFO [STDOUT] myFieldBean=org.jboss.aqbug.MyBean@1d9604
      16:42:45,036 INFO [STDOUT] Called testBar
      16:42:45,037 INFO [STDOUT] myFieldBean=org.jboss.aqbug.MyBean@1d9604

      Attachments

        Activity

          People

            Unassigned Unassigned
            ssilvert@redhat.com Stan Silvert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: