有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Get()和Set()在多个@Test、Selenium WebDriver之间

我正在使用Selenium WebDriver和Arquillian无人机进行这些测试

我的测试是如何构建的:

@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"));
  }

}

当我设置该值时,一切似乎都正常,但当我切换到另一个测试时,IdPo为空每个@Test是否可能释放和更新变量


共 (1) 个答案

  1. # 1 楼答案

    我相信考试前应该会帮助你

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

    只需编写一个方法,并用@BeforeTest注释它,然后根据需要设置值