Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Junit将@Test方法中的一些值传递到@Rule方法中_Java_Selenium_Junit - Fatal编程技术网

Java Junit将@Test方法中的一些值传递到@Rule方法中

Java Junit将@Test方法中的一些值传递到@Rule方法中,java,selenium,junit,Java,Selenium,Junit,我使用Junit作为Selenium框架的一部分运行测试。我需要将实际测试方法中的一些值记录到另一种方法中 @Rule public final RuleChain rules = RuleChain.outerRule( Watcher.newBuilder() .addCustomProperty("key", "value") .addCustomProperty("

我使用Junit作为Selenium框架的一部分运行测试。我需要将实际测试方法中的一些值记录到另一种方法中

    @Rule
  public final RuleChain rules =
      RuleChain.outerRule(
              Watcher.newBuilder()
                  .addCustomProperty("key", "value")
                  .addCustomProperty("key", "value")
                  .addCustomProperty("key", "value")
      );

 @Test
  public void someTest() {
   String a = "newValue";   //this need to be passed into @Rule "value"
   String b = "newValue";   //this need to be passed into @Rule "value"
   String c = "newValue";   //this need to be passed into @Rule "value"
}

我只是在猜。但是,为什么不将这些值设置为测试类的实例属性并在规则中提取它们呢?尽管测试最佳实践表明JUnit测试应该是自包含的,而不是相互依赖的。考虑到它们可以以随机顺序执行。。。