2 Replies Latest reply on Oct 24, 2016 11:28 AM by jjfraney

    junit-standalone runs a @Test 4 times!  why?

    jjfraney

      I'm trying out arquillian-junit-standalone.  I noticed something weird: A @Test method was running multiple times...and I want it to run once.

       

      I worked out a simple example.  attached as a zip file.  To run, use:

      mvn clean compile test failsafe:integration-test verify

       

      You will see this in the output:

      -------------------------------------------------------

      T E S T S

      -------------------------------------------------------

      Running org.sample.SampleIT

      running the test

      running the test

      running the test

      running the test

      Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.341 sec - in org.sample.SampleIT

       

       

       

      Here is the @Test method,

          @Test

          @RunAsClient

          public void testPlay() {

              System.out.println("running the test");

          }

       

      Thanks,

      John

        • 1. Re: junit-standalone runs a @Test 4 times!  why?
          mjobanek

          Hi,

          if you want to use only junit-standalone, then remove the arquillian-junit-container dependency.

          If you want to use both of them (standalone as well as container) then use only the arquillian-junit-container dependency as it transitively fetches also the standalone dependency.

          In addition, in the standalone mode you don't have to specify @RunAsClient annotation

          • 2. Re: junit-standalone runs a @Test 4 times!  why?
            jjfraney

            Thanks,

             

            I will make only one of your suggested edits: removing arquillian-junit-standalone.  Such is adequate to relieve the issue.  Thanks for the correct answer.

             

            FYI:

            1) when I remove dependency arquillian-junit-container, a compiler error: mvn clean test-compile 

               [ERROR] /home/jfraney/projects/multitest/src/test/java/org/sample/SampleIT.java:[3,47] package org.jboss.arquillian.container.test.api does not exist

            2) when I remove @RunAsClient, a warning when running the test: mvn clean test failsafe:integration-test verify

               WARNING: The test method "org.sample.SampleIT testPlay" will run on the client side - there is no running deployment yet. Please use the annotation @RunAsClient