您的位置:首页 > 其它

测试程序书写技巧

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);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: