在我的基础上,我通过提供基础URI和头等来创建请求规范。
RequestSpecification base = given().baseUri( " http://xyz/" )
.port( 8080 )
.header( "Content-Type", "application/json" );
而在我的子 classB
我复制了基础实例,并在子类中添加了路径参数。
RequestSpecification classB= base.given()
classB.pathParam("name", "abc" );
但当我试图将基类复制到另一个子类(不需要路径参数)时,它却抛出异常,因为路径参数的数量无效。预期为1,但实际为0。
在更新路径参数时,在 ClassB
有什么办法可以复制基类对象而不被更新.您的意见将非常感激!
而不是 "应用..."。
RequestSpecification classB = base.given();
classB.pathParam("name", "abc" );
尝试。
RequestSpecification classB = given().spec(base);
这里是 spec(RequestSpecification requestSpecification)
添加来自预定义RequestSpecification对象的数据。
检查 文件