将LogicUnitTest设置applicationunittests:如果在新建工程的时候选择Includeunittests,则系统会默认生成一个测试target,并配置为applicationunittests 。如果新建工程时没有选择包含单元测试,则在新建LogicUnitTest单元测试的Target之后,可以按如下步骤配置applicationunittests:1、选择新建的LogicUnitTest单元测试target,并选择BuildSetting栏和“All”2、在searchbar里面输入BundleLoader,将其值设置为$(BUILT_PRODUCTS_DIR)/.app/效果如下3、搜索TestHost,设置其值为$(BUNDLE_LOADER)效果如图4、使新建的单元测试target依赖与编译应用的target,效果如图5、如果是在新建的时候系统默认新建了scheme,则可以通过新的scheme来进行applicationtests,如果没有默认新建scheme,则可以编辑用来编译工程的scheme,选择左侧的Test如图:点击底部的“+”,将单元测试的target添加进来 。
如图这样原来的logicunittests就配置成applicationunittests了 。可以按运行logicunittests的方法运行applicationunittests,来验证是否配置正确 。
选择Product->Test(或者Command+U)可以对比LogicUnitTest运行完的report和ApplicationUnitTest运行的report有不一样的地方,就是上图方框这一栏ApplicationUnitTest 。
3.如何做单元测试单元测试步骤:
在代码编写完成后的单元测试工作主要分为两个步骤:人工静态检查和动态执行跟踪 。
人工静态检查是测试的第一步,这个阶段工作主要是保证代码算法的逻辑正确性(尽量通过人工检查发现代码的逻辑错误)、清晰性、规范性、一致性、算法高效性 。并尽可能的发现程序中没有发现的错误 。
第二步是通过设计测试用例,执行待测程序来跟踪比较实际结果与预期结果来发现错误 。经验表明,使用人工静态检查法能够有效的发现30%到70%的逻辑设计和编码错误 。但是代码中仍会有大量的隐性错误无法通过视觉检查发现,必须通过跟踪调试法细心分析才能够捕捉到 。所以,动态跟踪调试方法也成了单元测试的重点与难点 。
4.请问大神,用Jgoogletest是一个用来写C++单元测试的框架,它是跨平台的,可应用在windows、linux、Mac等OS平台上 。
下面,我来说明如何使用最新的1.6版本gtest写自己的单元测试 。本文包括以下几部分:1、获取并编译googletest(以下简称为gtest);2、如何编写单元测试用例;3、如何执行单元测试 。
4、google test内部是如何执行我们的单元测试用例的 。1. 获取并编译gtestgtest试图跨平台,理论上,它就应该提供多个版本的binary包 。
但事实上,gtest只提供源码和相应平台的编译方式,这是为什么呢?google的解释是,我们在编译出gtest时,有些独特的工程很可能希望在编译时加许多flag,把编译的过程下放给用户,可以让用户更灵活的处理 。这个仁者见仁吧,反正也是免费的BSD权限 。
5.junit怎么写下面是我做项目时的例子,希望对你有所帮助 。
/* *@author ougaoyan ,date:2008-10-19 */ package test; import java.util.Date; import junit.framework.TestCase; import app.DA.BookDA; import app.PD.Book; public class TestBookDA extends TestCase { public TestBookDA(String name){ super(name); } // public Book(int bookID, String cip, String name, String author,String press, String category, int quantity, int reborrowable,int borrowerID,Date startDate) public void testEditBook(){ Book book1 = new Book(1,"123456","信号","张建","某出版社","电信",1,1,1,new Date()); Book book2 = new Book(-1,"123456","信号","张建","某出版社","电信",1,1,1,new Date()); Book book3 = new Book(99,"123456","信号","张建","某出版社","电信",1,1,1,new Date()); Book book4 = new Book(1,"123456","信号","张建","某出版社","电信",1,1,1,new Date()); assertEquals(true,BookDA.editBook(book1)); assertEquals(false,BookDA.editBook(book2)); assertEquals(true,BookDA.editBook(book3)); assertEquals(false,BookDA.editBook(book4)); } ////Book(int borrowerID, Date startDate, int reBorrowable, String cip) public void testAddBook(){ Book book1 = new Book(0,"234567","信发号","张建","某出版社","电信",1,1,1,new Date()); Book book2 = new Book(0,"123456","信的号","张建","某出版社","电信",1,1,1,new Date()); Book book3 = new Book(0,"99999","信i号","张建","某出版社","电信",1,1,1,new Date()); assertEquals(true,BookDA.addBook(book1)); assertEquals(true,BookDA.addBook(book2)); assertEquals(false,BookDA.addBook(book3)); } public static void main(String[] args) { junit.textui.TestRunner.run(TestBookDA.class); System.out.println(new TestBookDA("TestBookDA").countTestCases()); } } /* *@author ougaoyan ,date:2008-10-19 */ package test; import java.util.Date; import java.util.Vector; import junit.framework.TestCase; import app.DA.CipDA; import app.PD.Cip; public class TestCipDA extends TestCase { public TestCipDA (String name){ super(name); } public void testFindBooksByName(){ String name1 = "数据库"; String name2 = "小小"; Vector vector1 = CipDA.findBooksByName(name1); Vector vector2 = CipDA.findBooksByName(name2); assertNotNull(vector1); assertNull(vector2); } public void testFindBooksByAuthor(){ String name1 = "欧阳"; String name2 = "小小"; Vector vector1 = CipDA.findBooksByAuthor(name1); Vector vector2 = CipDA.findBooksByAuthor(name2); assertNotNull(vector1); assertNull(vector2); } public void testFindBooksByCategory(){ String name1 = "计算机"; String name2 = "计 算 机"; String name3 = "wucimin"; Vector vector1 = CipDA.findBooksByCategory(name1); Vector vector2 = CipDA.findBooksByCategory(name2); Vector vector3 = CipDA.findBooksByCategory(name3); assertNotNull(vector1); assertNotNull(vector2); assertNull(vector3); } // public void testEditCip(){ // } //public Cip(String cip, String name, String author, String press,String category, int quantity, int reserverID,Date reservedDate) public void testAddCip(){ Cip cip1 = new Cip("2244","新加书","新者","出版社","计算机",3,0,new Date()); //Cip cip2 =new Cip(null,"新加书","新者","出版社","计算机",3,0,new Date()); Cip cip3 =new Cip("22er3rr3rt4t43t43t3t34t34t34t44","新加书","新者","出版社","计算机",3,0,new Date()); assertEquals(true,CipDA.addCip(cip1)); //assertEquals(false,CipDA.addCip(cip2)); assertEquals(false,CipDA.addCip(cip3)); } public void testEditCip(){ Cip cip1 = new Cip("2244","新加书","新者","出版社","计算机",3,0,new Date()); Cip cip2 =new Cip(null,"新加书","新者","出版社","计算机",3,0,new Date()); Cip cip3 =new Cip("22er3rr3rt4t43t43t3t34t34t34t44","新加书","新者","出版社","计算机",3,0,new Date()); assertEquals(true,CipDA.editCip(cip1)); assertEquals(false,CipDA.editCip(cip2)); assertEquals(false,CipDA.editCip(cip3)); } public static void main(String[] args) { junit.textui.TestRunner.run(TestCipDA.class); System.out.println(new TestCipDA("TestCipDA").countTestCases()); } } /* *@author ougaoyan ,date:2008-10-19 */ package test; import java.util.Date; import java.util.Vector; import junit.framework.TestCase; import app.DA.LibManagerDA; import app.PD.LibManager; import app.PD.Student; public class TestLibManagerDA extends TestCase { public TestLibManagerDA(String name){ super(name); } public void testCheck() 。
- 英语键盘单词怎么写
- html输入代码怎么写
- 木棍单词怎么写
- 肉鸡总结怎么写
- 初二的成长记录怎么写
- 日语中的假名怎么写
- 诉讼请求利息怎么写
- 去游泳用英文怎么写
- function函数怎么写
- 淋浴的英语单词怎么写