如图这样原来的logicunittests就配置成applicationunittests了 。可以按运行logicunittests的方法运行applicationunittests,来验证是否配置正确 。
选择Product->Test(或者Command+U)可以对比LogicUnitTest运行完的report和ApplicationUnitTest运行的report有不一样的地方,就是上图方框这一栏ApplicationUnitTest 。
2.请问大神,用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权限 。
3.zk代码怎么做unit test往简单了说,在没有返回值的方法前加上@Test ,然后将junit的jar包引入就好了 。
这个ide都会有的,直接引入就行了,简单代码如下:然后run as junit test就可以运行了public class IntegerTest {@Testpublic void test() {Integer i1 = new Integer(2) ;Integer i2 = new Integer(2) ;Integer i3 = 35;Integer i4 = 35;System.out.println(i3==i4);}} 。
4.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 (){ 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("","新加书","新者","出版社","计算机",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("","新加书","新者","出版社","计算机",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() 。
- 离职申请书格式怎么写
- mvmt官网地址怎么写
- mvc文件的href怎么写
- 一个山加一个介怎么写
- mvc文件地址怎么写
- matlab书籍封面的图怎么写
- 施工事故处理报告怎么写
- 硫化氢的电子式怎么写
- 老师人物专访怎么写
- e自然小调怎么写