当前位置: 动力学知识库 > 问答 > 编程问答 >

Repeating TestNG or Junit test suite

问题描述:

I trying to repeat login_logout.class 10 times. Why can't I repeat this 10 times?

@RunWith(Suite.class)

@SuiteClasses({login_logout.class})

public class AllTests {

@Parameters

public static Collection<Object[]> getData(){

Object[][] data = new Object[10][0];

return Arrays.asList(data);

}

}

网友答案:

My understanding is "new Object[10][0]" is to construct an two-dimension array:

(1) [10][0] mean the array has 10 lines that each line holds zero object ==> Is it supposed to be "[10][1]" ?

(2) As only the code you uploaded, you didn't actually create any real object, because the "new Object[10][0]" only make an array not any real object

网友答案:

The Suite test runner doesn't support parameters. You could rewrite login_logout as a parameterized test:

@RunWith(Parameterized.class)
public class LoginLogoutTest {
  @Parameterized.Parameters
  public static Collection<Object[]> values() {
    return Arrays.asList(
        new Object[10][1]);
  }

  public LoginLogoutTest(Object ignored) {
  }

  @Test
  public void doSomething() {
  }
}

That being said, I can't think of too many use cases for running the exact same test ten times.

分享给朋友:
您可能感兴趣的文章:
随机阅读: