[arquillian-issues] [JBoss JIRA] (ARQGRA-382) Make @InitialPage work for Field

Vsevolod Golovanov (JIRA) issues at jboss.org
Thu Aug 10 08:03:00 EDT 2017


    [ https://issues.jboss.org/browse/ARQGRA-382?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13444441#comment-13444441 ] 

Vsevolod Golovanov edited comment on ARQGRA-382 at 8/10/17 8:02 AM:
--------------------------------------------------------------------

bq. However, all other fields in tests preserve the state among tests, so Before would be an exception.
That seems worrisome, does this imply that the page instances behind \@Page fields survive between test methods? JUnit creates a new test class instance for each of the \@Test methods - each of those runs is supposed to be a self-contained independent execution unaffected by other runs. One method execution seems to be a proper natural scope for \@InitialPage too. -It also mirrors the default Drone instance scope- (Update: I forgot, the default is class scope.) (but I don't think these scopes should always be equated, though class scoped InitialPage certainly makes no sense with a method scoped Drone).

Maybe {{\@InitialPage static_field}} = BeforeClass, {{\@InitialPage instance_field}} = Before? Gotta not break parallel execution though...

Update.
JUnit doesn't have a defined \@Test method execution order. In practice the order often changes between runs. Keeping this in mind, a BeforeClass-like InitialPage doesn't make much sense, unless all the tests somehow guarantee that they won't affect each other, even though they all execute on the same opened page? This is very dubious.
TestNG doesn't specify the execution order by default either, but has {{\@Test(priority, dependsOnGroups, dependsOnMethods)}}.
I think InitialPage on a field should just always be considered method-scoped (\@Test-scoped).


was (Author: vsevolodgolovanov):
bq. However, all other fields in tests preserve the state among tests, so Before would be an exception.
That seems worrisome, does this imply that the page instances behind \@Page fields survive between test methods? JUnit creates a new test class instance for each of the \@Test methods - each of those runs is supposed to be a self-contained independent execution unaffected by other runs. One method execution seems to be a proper natural scope for \@InitialPage too. -It also mirrors the default Drone instance scope- (Update: I forgot, the default is class scope.) (but I don't think these scopes should always be equated, though class scoped InitialPage certainly makes no sense with a method scoped Drone).

Maybe {{\@InitialPage static_field}} = BeforeClass, {{\@InitialPage instance_field}} = Before? Gotta not break parallel execution though...

> Make @InitialPage work for Field
> --------------------------------
>
>                 Key: ARQGRA-382
>                 URL: https://issues.jboss.org/browse/ARQGRA-382
>             Project: Arquillian Graphene
>          Issue Type: Enhancement
>          Components: core
>    Affects Versions: 2.0.0.CR1
>            Reporter: Karel Piwko
>             Fix For: 2.0-Tracking
>
>
> While @InitialPage allows to be used on test class field, it does not do anything.
> {code}
> @InitialPage AddUserPage page;
> @Test
> void test() {
>     page.foo()
> }
> {code}
> raises
> {code}
> java.lang.NullPointerException: null
>         at com.acme.example.test.DroneTest.addUser(DroneTest.java:35)
> {code}



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the arquillian-issues mailing list