@ parameters in JUnit 4

Can I use multiple @ parameters methods in JUnit test classes running with the parameterized class?

@RunWith(value = Parameterized.class)
public class JunitTest6 {

 private String str;

 public JunitTest6(String region,String coverageKind,String majorClass,Integer vehicleAge,BigDecimal factor) {
    this.str = region;
 }

  @Parameters
 public static Collection<Object[]> data1() {
   Object[][] data = {{some data}}

   return Arrays.asList(data);
 }

 @Test
 public void pushtest() {
   System.out.println("Parameterized str is : " + str);
   str = null;
 }

 @Parameters
 public static Collection<Object[]> data() {
   Object[][] data = {{some other data}}
   return Arrays.asList(data);
 }

 @Test
 public void pulltest() {
   System.out.println("Parameterized new str is  : " + str);
   str = null;
 }
}

Solution

You can use theories runner to pass different parameters to different methods

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>