Junit-standalone with @RunAsClient executes test method twice


#1

Hi

Lets have arquillian-junit-container jar on CP and this test:

@RunWith(Arquillian.class)
@RunAsClient
public class SomeTestCase
{
    @Test
    public void test()
    {
        System.out.println("test");
    }
}

This test method writes out “test” here:

(E) Test
    (I) TestContextHandler.createSuiteContext
    (I) TestContextHandler.createClassContext
    (E) TestClass
    (I) TestContextHandler.createTestContext
    (I) ContainerEventController.createTestContext
    (O) ClientTestExecuter.execute
    (E) ExecutionEvent
    (O) LocalTestExecuter.execute
test
    (E) TestResult

So, all is good.

Now, take the very same test, nothing has changed at all, but use arquillian-junit-standalone instead of junit-container and see the output:

(E) Test
    (I) TestContextHandler.createSuiteContext
    (I) TestContextHandler.createClassContext
    (E) TestClass
    (I) TestContextHandler.createTestContext
    (I) ContainerEventController.createTestContext
    (O) ClientTestExecuter.execute
    (E) ExecutionEvent
        (O) LocalTestExecuter.execute
test
    (E) TestResult
    (O) LocalTestMethodExecutor.execute
test
    (E) TestResult

Why it is printed out twice when using junit-standalone? I am using Droidium container on CP in every case. It holds also for having @RunAsClient on test methods.

Firstly I spotted this when that test method has written something out to fields (username / password). In case I had junit-standalone on cp, that method was executed twice so I ended up with two names and two passwords written in textfields (namename / passwordpassword) and it was obvious that something is weird here … that method was just executed twice …


#2

Could you provide the output from mvn dependency:tree ?


#3

Aslak, I believe that same happens with arquillian-rules-extension here:


#4

@miklosovic I think you’re including too much in your dep chain. @RunAsClient is a Container thing and should not be on ClassPath when executing Standalone. If it is, it’s most likely also pulling in the RemoteTestRunner, meaning you now have two Observers for @Test


#5

@aslak

Sorry for late response.

So right now when I have Droidium test which runs all as client, I have junit-container on cp an all behaves ok.

But when I change it to junit-standalone it is also executed twicely so no change here …

I did some local changes to droidium poms which are not yet upstream, it was pulling junit-standalone in test scope since I needed it in integration tests of Droidium itself, I remove it and replaced it with test-impl-base.

I attach dep tree of test project when I get that test method executed twice:

But maybe that test-impl-base does register these observers anyway so I end up with two of them, it has scope of “test” so it would eventually get registered even I run ordinary mvn test on test project itself.

EDIT:

i need to refactor these poms and deps little bit … i am sure I have it wrong


#6

arquillian-droidium-native-spi depend on arquillian-container-test-impl-base. arquillian-container-test-impl-base overrides arquillian-test-impl and registeres the LocalTestMethodExecutor. arquillian-junit-standalone also registers LocalTestMethodExecutor.