测试程序书写技巧
2015-12-26 22:25
363 查看
package testForJunit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import com.ai92.cooljunit.WorddealUtil;
public class TestWordDealUtil {
// 测试 wordFormat4DB 正常运行的情况
@Test public void wordFormat4DBNormal(){
String target = "employeeInfo";
String result = WorddealUtil.wordFormat4DB(target);
//チェック実行
assertEquals("employee_info", result);
}
// 测试 null 时的处理情况
@Test public void wordFormat4DBNull(){
String target = null;
String result = WorddealUtil.wordFormat4DB(target);
//チェック実行
assertNull(result);
}
// 测试空字符串的处理情况
@Test public void wordFormat4DBEmpty(){
String target = "";
String result = WorddealUtil.wordFormat4DB(target);
//チェック実行
assertEquals("", result);
}
// 测试当首字母大写时的情况
@Test public void wordFormat4DBegin(){
String target = "EmployeeInfo";
String result = WorddealUtil.wordFormat4DB(target);
//チェック実行
assertEquals("employee_info", result);
}
// 测试当尾字母为大写时的情况
@Test public void wordFormat4DBEnd(){
String target = "employeeInfoA";
String result = WorddealUtil.wordFormat4DB(target);
//チェック実行
assertEquals("employee_info_a", result);
}
// 测试多个相连字母大写时的情况
@Test public void wordFormat4DBTogether(){
String target = "employeeAInfo";
String result = WorddealUtil.wordFormat4DB(target);
//チェック実行
assertEquals("employee_a_info", result);
}
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import com.ai92.cooljunit.WorddealUtil;
public class TestWordDealUtil {
// 测试 wordFormat4DB 正常运行的情况
@Test public void wordFormat4DBNormal(){
String target = "employeeInfo";
String result = WorddealUtil.wordFormat4DB(target);
//チェック実行
assertEquals("employee_info", result);
}
// 测试 null 时的处理情况
@Test public void wordFormat4DBNull(){
String target = null;
String result = WorddealUtil.wordFormat4DB(target);
//チェック実行
assertNull(result);
}
// 测试空字符串的处理情况
@Test public void wordFormat4DBEmpty(){
String target = "";
String result = WorddealUtil.wordFormat4DB(target);
//チェック実行
assertEquals("", result);
}
// 测试当首字母大写时的情况
@Test public void wordFormat4DBegin(){
String target = "EmployeeInfo";
String result = WorddealUtil.wordFormat4DB(target);
//チェック実行
assertEquals("employee_info", result);
}
// 测试当尾字母为大写时的情况
@Test public void wordFormat4DBEnd(){
String target = "employeeInfoA";
String result = WorddealUtil.wordFormat4DB(target);
//チェック実行
assertEquals("employee_info_a", result);
}
// 测试多个相连字母大写时的情况
@Test public void wordFormat4DBTogether(){
String target = "employeeAInfo";
String result = WorddealUtil.wordFormat4DB(target);
//チェック実行
assertEquals("employee_a_info", result);
}
}
相关文章推荐
- kettle生成100个随机数,并统计小于等于50和大于50个数
- 20151223:Web:审核:审核和取消
- Eclipse Helios 配置 Android SDK 2.3 和 ADT 0.9.9
- Ubuntu下使用Apache2反向代理php应用
- 2015年年终总结
- 2015/12/26--jquery(02)
- Uber License for Android
- VC++通过ODBC将数据导出到excel
- Linux之网络配置详解
- Ubuntu / Linux Mint本地安装MySQL
- 简单的发短信,难不倒程序员
- Android handler 可能会造成内存泄露
- ORA-01105---spfile in $ORACLE_HOME/dbs VS spfile in ASM
- Git学习
- ORA-01090: shutdown in progress - connection is not permitted
- OC中枚举和排序
- 20151223:Web:审核:主页面
- JavaScrip——练习(求整数和、求整数积)
- Linux学习笔记2:如何快速的学习使用一个命令
- hdu 5593 ZYB's Tree(树形dp)