简体   繁体   中英

Get() and Set() between multiple @Test, Selenium WebDriver

I'm using Selenium WebDriver and Arquillian drone for these test.

how my tests are build :

@RunWith(Arquillian.class)
public class SimpleTest{

  private String idPo;

  public String getIdPo() {
    return idPo;
  }

  public void setIdPo(String id) {
    idPo = id;
  }

  @Test
  public void setTest() {
    setIdPo("5");
  }

  @Test
  public void getTest() {
    String temp = getIdPo(); // ----> returns null
    Assert.assertTrue(temp.equals("5"));
  }

}

When i set the value, everything seems to be ok, but when i switch to another test, IdPo is null. Is it possible that each @Test release and renew variables ?

I've found the error...

When i call the getter i was using : getId() instead of getIdPo() .

But Eclipse never underline getId() .. don't really know why.. because it doesn't exist in my code..

I belive BeforeTest should help you.

@BeforeTest: The annotated method will be run before any test method belonging to the classes inside the tag is run.

Just write a method and annotate it with @BeforeTest and set the values as desired.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM