我在一个 Java 类中有多个方法,其中每个方法都有 20 多个参数。我将在另一个类中为这个类创建一个对象并调用每个方法。通常我在 Selenium Java 中使用 POM(页面对象模型)。因此,在每个 Page 对象类中,每个方法中都有多个(20 多个)参数,我将在测试类中调用它们。
页面对象类:
public void enterShipInfo(String IMO,String Vstat,String Vcode,String Vname,
String Vtype,String Officialno,String Buildyr,String Shipyard,String Hullno,String Layingdate,
String Launcheddate,String Deliverdate,String Reportinclude,String Portregistry,String VFlag,
String Vstatus,String Classification,String Classid,String Classnotation,String PI,String HM,
String Regowner,String Shipmanager,String Comoperator,String Callsign,String SSR,String Factor,
String ELOG,String Vcomments,String VsisIMO,String Chartertype,String Showonweb){
}
.... Other Methods with similar long list of parameters
然后在测试类中,我再次为这些创建参数:
public class VesTest {
@Test(dataProvider="Ves",priority=1)
public void createVesTest(String IMO,String Vstat,String Vcode,String Vname,
String Vtype,String Officialno,String Buildyr,String Shipyard,String Hullno,String Layingdate,
String Launcheddate,String Deliverdate,String Reportinclude,String Portregistry,String VFlag,
String Vstatus,String Classification,String Classid,String Classnotation,String PI,String HM,
String Regowner,String Shipmanager,String Comoperator,String Callsign,String SSR,String Factor,
String ELOG,String Vcomments,String VsisIMO,String Chartertype,String Showonweb
Mdr_Vessel obj_Mdr_Vessel = page(Mdr_Vessel.class);
obj_Mdr_Vessel.clickSubmenu();
.....
}
有什么有效的方法可以减少在测试类中再次输入参数???我不想将方法分解为多个方法。所以请建议我一种以有效方式传递参数的方法