testcartmethod.java~15~
来自「购物车模块实例。购物车模块可以浏览商品类别;可以根据商品类别浏览商品信息;可以购」· JAVA~15~ 代码 · 共 29 行
JAVA~15~
29 行
package junittest;
import junit.framework.*;
import data.*;
public class TestCartMethod extends TestCase {
private CartMethod cartMethod = null;
protected void setUp() throws Exception {
super.setUp();
cartMethod = new CartMethod();
}
protected void tearDown() throws Exception {
cartMethod = null;
super.tearDown();
}
//测试分解分符串的方法
public void testDecodeGoodsStr() {
String goodStr = "糖果@@每箱30盒@@10@@5";
String[] actualReturn = cartMethod.decodeGoodsStr(goodStr);
assertEquals("return value", "每箱30盒", actualReturn[1]);
}
//测试四舍五入的方法,保留2个小数点
public void testRoundUp(){
double num = 16.753;
double actualReturn = cartMethod.roundUp(num)
assertEquals("return value", 16.75, );
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?