• TestNG官方文档及TestNG-参数传递几种方式


    TestNG官方文档 https://www.jianshu.com/p/d430c78016e6

     

    TestNG-参数传递几种方式  https://blog.csdn.net/xueningyang555/article/details/88871426

     

    如下,向监听器,类等传递参数可以通过如下

    @BeforeSuite
    @Parameters({"baseurl","account","password"})
    public void beforeSuite(String baseurl,String account,String password  ){
        this.baseurl=baseurl;
        this.account=account;
        this.password=password;
    }

    @Listeners(MyListener.
    class) @Test(testName = "MyTest") public class MyTest { @Parameters({ "apiurl", "useratorg", "password", "catalogname", "vapptemplatename", "vappusr", "vapppwd", "jobid" }) @BeforeClass public void setUpConnectionProperties(String apiUrl, String userAtOrg, String password, String catalogName, String vAppTemplateName, String vAppUsr, String vAppPwd, String jobId) { ...} }
    public class MyListener extends TestListenerAdapter { @Override public void onStart(ITestContext testContext) { jobId = testContext.getSuite().getParameter("jobid"); super.onStart(testContext); } }

    @BeforeMapping 用法

    public interface MappingCustomizer {
        @BeforeMapping
        void calledBefore(BaseEntity source);
    
        @AfterMapping
        void calledAfter(BaseEntity source, @MappingTarget BaseDTO target);
    }
    
    @Mapper( uses = { ..., MappingCustomizer.class } )
    public interface PersonMapper {
    ...
    }
    
    public class PersonMapperImpl implements PersonMapper {
        @Inject
        private MappingCustomizer mappingCustomizer;
    
        @Override
        public PersonDTO entityToDTO(Person source) {
            mappingCustomizer.calledBefore(source); // because Person extends BaseEntity, and the @BeforeMapping method is applicable
    
            PersonDTO personDto = new PersonDTO();
            // ... property mapping
    
            mappingCustomizer.calledAfter(source, personDto); // because the source parameters and the target type are applicable
    
            return personDto;
        }

    https://github.com/mapstruct/mapstruct/issues/14

  • 相关阅读:
    夏令营讲课内容整理 Day 6 Part 3.
    夏令营讲课内容整理 Day 6 Part 2.
    计算几何:模板
    字符串:SAM
    字符串:回文自动机
    字符串:马拉车
    数学&模拟:随机化-矩阵随机化
    模拟:随机增量法
    模拟:爬山算法与模拟退火算法
    模拟:压位高精度
  • 原文地址:https://www.cnblogs.com/yuluoxingkong/p/12302621.html
Copyright © 2020-2023  润新知