• 已提交

  • 参数化:
    @DataProvider
    public Object[][] getBuys(){
    return new Object[][]{
    {"","",1,0,-2,"未登录测试"}, //未登录
    {"test1","123456",1,0,-1,"购买0个商品测试"}, //购买0个商品
    {"test1","123456",2,1,1,"购买小于库存数商品测试"}, //正常购买
    {"test1","123456",3,2,0,"购买大于库存数商品测试"}, //库存不够
    };
    }

    测试代码:
    @Test(dataProvider = "getBuys",dataProviderClass = LoginParams.class)
    public void testBuys(String name,String pwd,int proid,int count,int expect,String message){
    System.out.println(message);
    login.userLogin(name,pwd);
    if(login.isLogin == false){
    Assert.assertEquals(-2,expect);
    }
    else{
    int actual = shopping.buys(proid,count);
    Assert.assertEquals(actual,expect);
    }
    }
    testng.xml 设置

    执行结果:

  • 作业:
    1、提取系统state连接种类
    Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
    2、teserhome 某一精华帖任意一回复贴的数量
    任意一个精华帖会有多个回复、找出任意一个回复贴的点赞数
    解:

    1. netstat -ntp | sed 1,2d | awk '{print$6}' | sort | uniq -c | sort -n
    2. curl https://testerhome.com 2>/dev/null | grep -b1 "fa fa-diamond" | grep "href" | awk -F "\"" '{print $4}' | grep "topics" | while read line;do count=$(curl https://testerhome.com$line 2>/dev/null | grep "data-count.*likeable" | grep "Reply" | awk -F "\"" '{print $4}');echo $line 回帖的点赞为is $count;done