本文共 3971 字,大约阅读时间需要 13 分钟。
@Test(description = "getNewestItems_冒烟_获取最新商品并检查若干关键属性") public void test_getNewestItems_smoke() { List<ItemVo> itemList = itemBean.getNewestItems(1); Assert.assertTrue(itemList.size() == 16, "size应该是16"); for (ItemVo vo : itemList) { Assert.assertTrue(vo.getName() != null, "name不能为空"); Assert.assertTrue(vo.getPrice() != null, "price不能为空"); } } |
@Test(description = "enter_and_leave_market_冒烟_进入与离开超市") public void test_enter_and_leave_market_smoke() { Custom tom = new Custom("Tom"); tom.enterMarket(); Assert.assertTrue(Custom.isAtMarket(tom), "tom应该在超市内"); tom.leaveMarket(); Assert.assertFalse(Custom.isAtMarket(tom), "tom应该不在超市"); } |
@Test(description = "addToCart_正常流程_往购物车内添加各种类型数目的商品", dataProvider = "test_addToCart_normal_data") @Rollback public void test_addToCart_normal(String caseNote, long itemId, int count) { Custom tom = new Custom("Tom"); this.setCustom(tom); cartBean.addToCart(itemId, count); Item item = tom.getCart.getItems.get(0); // 获取购物车中的第一项商品 Assert.assertEquals(item.getId, itemId, "itemId is wrong"); Assert.assertEquals(item.getCount, count, "count is wrong"); } @DataProvider public Object[][] test_addToCart_normal_data() { return new Object[][] { // caseNote, itemId, count {"Milk - just a dozen", 39001L, 12, }, {"Bread - huge number", 116001L, 999}, {"Bean - less then 10", 1018100L, 2}, }; } |
@Test(description = "addToCart_异常流程_往购物车内添加参数非法的商品", dataProvider = "test_addToCart_error_data") @Rollback public void test_addToCart_error(String caseNote, long itemId, int count, int expectedErrorCode) { Custom tom = new Custom("Tom"); this.setCustom(tom); try { cartBean.addToCart(itemId, count); Assert.fail(); } catch (Exception e) { Assert.assertEquals(e.getErrorCode, expectedErrorCode); } } @DataProvider public Object[][] test_addToCart_error_data() { return new Object[][] { // caseNote, itemId, count, expectedErrorCode {"iPad - 0 count", 39001L, 0, Cart.ZERO_COUNT}, {"MacBookPro - more then stock", 116001L, 1024, Cart.MORE_THAN_STOCK}, {"no such item", 0L, 1L, Cart.NO_SUCH_ITEM} }; } |
转载地址:http://ltgox.baihongyu.com/