第7章 单元测试及NUnit & JUnit
【英语】人教版年秋七年级英语上册unit7单元练习含答案

【关键字】英语Unit7 How much are these socks?单元练习一、单项选择(共15小题;共15分)1. --- How much the bottles of milk?--- 31 yuan.A. areB. isC. amD. be2. --- How much the socks?--- Three dollars.A. isB. areC. doD. does3. --- the job in the police station exciting?--- Yes. But it is also dangerous.A. DoB. DoesC. IsD. Are4. They can buy the pens a very good .A. at; priceB. in; priceC. at; costD. at; selling5. The beautiful house is sale. But it won't be sale.A. on; forB. for; onC. with; forD. with; on6. --- How much the hats?--- Five dollars.A. isB. areC. amD. /7. Some of my friends eat with their eyes. They prefer(更喜欢) to order(点) what nice.A. feelsB. smellsC. looksD. tastes8. How much the green sweater and the blue hat?A. isB. areC. doD. does9. John bought for himself yesterday.A. two pairs of shoesB. two pair of shoeC. two pair of shoesD. two pairs shoes10. --- ?--- Yes. I'd like the new dress. Please show me the green one.A. What's the matterB. How are youC. What's the dateD. Can I help you11. How much the CD and the book?A. isB. areC. doD. does12. How much these carrots?A. areB. isC. doD. does13. No news good news.A. isB. areC. wasD. were14. We sell these apples a good price.A. inB. atC. ofD. on15. The green shorts are for $25.A. on saleB. on sellC. for saleD. for sell2、单词拼写(单句首字母填空)(共10小题;共10分)16. Students n to study hard.17. I don't like young people who wears strange c with colorful hair.18. Look at that girl. Her s is very nice.19. My class has t students, ten girls and twenty boys.20. --- What's two and ten?--- It's t .21. The p of the computer is 5000 yuan. I can't afford it.22. This beautiful MP5 is on s in that shop, and it is very cheap, you can go and buy it.23. It's hot today, but he still wears a shirt and t . I like a T-shirt and shorts better.24. --- How much are these socks?--- They're nine d .25. A quarter (一刻钟) has f minutes(分钟).三、单词拼写(根据中文提示拼写单词)(共10小题;共10分)26. Look! Here are (十三) hats. Which one do you like?27. I want to buy (十一) watermelons.28. Look at his new (裤子). They are very beautiful.29. How many (双) of shoes are there under the bed?30. ---Have you heard about the news?---Yes. The (价格) of petrol(汽油) went up last month!31. How much are the (衣服)?32. The clothes are all on (出售).33. Here are (十五) pencils.34. I agree with you that she (需要) a good rest.35. I want to buy a (毛衣) for my mother.四、完形填空(共10小题;共15分)Dr. Brown was a very busy man. He always worked 36 . He often 37 his family's birthdays.Yesterday afternoon he 38 it was his wife's birthday. He loved his wife very much. He wanted 39 her a present. On his way 40 his hospital he bought some beautiful flowers in a shop.When Dr. Brown got home, he gave his wife the flowers and said, “Happy birthday 41 you, dear! It's October 3rd, I remember your birthday 42 year.”Mrs. Brown laughed and said, “My birthday was the day 43 yesterday. 44 thank you all the same, 45 late than never.”36. A. better B. difficult C. hard D. harder37. A. remembered B. forgot C. remembers D. forgets38. A. remembered B. forgot C. remembers D. forgets39. A. give B. giving C. to give D. gave40. A. to B. of C. on D. in41. A. for B. of C. with D. to42. A. last B. the C. on D. this43. A. after B. before C. of D. next44. A. But B. So C. And D. Even45. A. good B. better C. best D. more五、阅读理解(共20小题;共40分)AMr Brown saw a sweater in a shop window. It was very cheap, so he bought it. When he got home, he put it on. It was alright and he was pleased with it.In the afternoon, he went to work in his garden. It soon began to rain and Mr Brown had to run into the house. He ran quickly, but he still got wet. Then his sweater started to shrink(收缩)! It got smaller and smaller. Mr Brown tried to take it off, but he couldn't.In the end, with the help of his wife, he got out of the sweater. Mrs Brown laughed, “You see, you bought a cheap thing, but…”46. Mr Brown saw a nice in a shop window. And he bought it.A. jacketB. coatC. sweaterD. shirt47. When he , he put it on.A. got to the officeB. got homeC. went to workD. went to the shop48. It soon began to while he was working in the garden.A. rainB. snowC. cloudD. shine49. Mr Brown got wet and he tried to the sweater.A. take awayB. take offC. put upD. put on50. From the story, we know Mr Brown bought .A. a good sweaterB. an expensive sweaterC. a comfortable sweaterD. a cheap but not good sweaterBUncle Lee is coming to have dinner with us. Mom and I go shopping.We don't have any meat. We need to buy some. It's ten yuan a kilo before. But now two kilos are sixty yuan. I say, "Mom, let's buy some fish." Mom answers, "OK." Fish is Uncle Lee's favorite food. We buy one kilo and a half. We also buy some vegetables and some chicken, but we don't buy any hamburgers. Uncle Lee doesn't like them at all. Mom also wants to buy some apples for me. You know, I like bananas, oranges and peaches, but I like apples best. But we can't find any. We go home at a quarter to five in the afternoon.51. How much is meat now?A. Ten yuan a kilo.B. Fifteen yuan a kilo.C. Thirty yuan a kilo.D. Forty yuan a kilo.52. What doesn't Mom buy?A. Vegetables.B. Chicken.C. Hamburgers.D. Fish.53. Uncle Lee's favorite food is .A. fishB. chickenC. meatD. vegetable54. The author's favorite fruit is .A. applesB. bananasC. orangesD. peaches55. What time do they go home?A. At 5:15.B. At 4:45.C. At 5:45.D. At 6:00.CMy Name Is Very Very Long(长)Tom and Fred are students. They are twelve years old, and they are in the same class in their school. One afternoon, they have a fight(打架) in class, and their teacher is very angry(生气). He says to them,"Stay(留下) here after class (放学后), and write your names one hundred times(次)."After class, all the other students go home. Tom and Fred stay in the classroom with their teacher. They begin to write their names. Then Fred cries(哭). The teacher looks at him and says, "Why are you crying (哭什么)?""Because(因为) his name is Tom May, and my name is very, very long. My name is Frederick Hollingsworth." Fred says.56. One afternoon, they in class.A. have a testB. have a partyC. have a fightD. have a meeting57. The teacher lets them after class.A. go homeB. stay at schoolC. play computer gamesD. cry58. Their teacher asks them to write their names .A. two hundred timesB. three hundred timesC. one hundred timesD. ten times59. Fred cries because .A. his name is very, very long.B. he likes crying.C. he likes his name.D. he likes Tom's name.60. Where is their reacher?A. In the classroom.B. In his office.C. At home.DNow let me tell you something about the world. France and the U.K. are western countries. China, Korea and Singapore are eastern countries. Different countries have different food. Hamburgers, donutsand hot dogs are the favourite food in the western countries. Dumplings, rice and noodles are popular in China. The U.S. is very far from China. It is east of China. Singapore and Korea are near China. People in different countries speak different languages. Chinese speak Chinese and people in France speak French. Do Canadians speak English? Yes, they speak English and French. People in the U.S. also speak English. We call it American English.61. is in the west in the world.A. ChinaB. SingaporeC. KoreaD. The U.K.62. People in the U.S. like to eat .A. noodlesB. dumplingsC. hot dogsD. rice63. Korea is in the of the world.A. eastB. westC. southD. north64. We call people from Canada .A. ChineseB. CanadiansC. FrenchD. Korean65. is near China.A. The U.S.B. KoreaC. FranceD. The U.K.六、阅读与表达(判断式)(共5小题;共10分)Clouds are made of millions of very small drops of water. The drops move around all the time. When they hit each other, they join up. This is how they grow larger and heavier. When they are too heavy to stay in the air, they fall down as rain.If it is very cold, the very small drops of water change into ice. The pieces of ice freeze together. When they get too heavy, they fall down as snow.There are many different kinds of clouds. And they are different in shape. The thunderclouds are big and dark. Some clouds are like small white balls of cotton.根据短文内容,判断正误,正确的为T,错误的为F。
Unit7__精品单元测试

Unit7 精品单元测试听力,词汇A) 听力。
(20分) (本部分配有磁带)(1)听句子,选出你所听到的单词。
(每个句子读两遍,你有5秒钟答题时间)(5分)( ) 1. A. yellow B. green C. blue( ) 2. A. big B. small C. bag( ) 3. A. seven B. ten C. pen( ) 4. A. skirts B. shorts C. pants( ) 5. A. long B. short C. small(2) 听句子,选择与所听句子意思相符的图片。
(每个句子读两遍,你有10秒钟答题时间)(5分)( ) 6.( ) 7.( ) 8.( ) 9.( ) 10.(3)听对话和问题,选择正确答案。
(对话和问题读两遍,你有20秒钟答题时间)(5分)( ) 11. A. At school. B. At home. C. At a clothes store.( ) 12. A. Blue. B. Red. C. White.( ) 13. A. Five dollars. B. Four dollars. C. Fifteen dollars.( ) 14. A. Yes, she is. B. Yes, she does. C. No, she doesn’t.( ) 15. A. The woman. B. The man. C. We don’t know.(4)听短文,根据短文内容填空。
(短文读两遍,你有20秒钟答题时间)(5分)Hello, everyone!Welcome to Xiao Na Clothes Store. We have T-shirts, shorts, ______16, skirts and so on. They are all at a very good ______17. TheseT-shirts are 15 yuan ______18. For girls, we have great skirts ______19 red, green, white. The shorts are for only 4 yuan. Come and see for yourself. You can ______20 our prices.B) 词汇。
Unit 7 单元测试卷(含答案详解)

Unit7单元测试卷(时间:75分钟满分:90分)一、语法选择(本大题共10小题,每小题1分,共10分)Most parents hope that their children can be happy and successful. But what's __1__ way of all to encourage them to become so? The answer is to allow them to make __2__ own decisions.However, many parents __3__ decisions for their children all the time. In fact, it's not good __4__ children's growth.Children should _15__ to make decisions. But this doesn't mean they can do everything. For example, you can take your children into a store __6__ give them a choice among snacks. When children get older, you can increase __7__ number of choices you give them. For example, allow them to decide the activities they want to take part in.The next step is to let your children think __8__ before they act. Let them ask themselves several __9__. First, why do I want to do this? Second, what are my choices? Third, what are the results of the actions? After that, they are sure __10__ right decisions. Let's give a chance to children to make their own decisions!( )1. A. good B. better C. the best( )2. A. they B. them C. their( )3. A. make B. made C. will make( )4. A. of B. for C. from( )5. A. allow B. be allowed C. be allowing( )6. A. and B. but C. as( )7. A. a B. an C. the( )8. A. care B. careful C. carefully( )9. A. question B. questions C. question's( )10. A. to have B. have C. having二、完形填空(本大题共10小题,每小题1分,共10分)Nevaeh, Raymond, and I were playing tag(捉捉捉捉). Nevaeh just tagged me, and I was trying to tag her back. “No tagging back捉” Nevaeh shouted as I started to __1__ her.“We didn't make rules for this game of tag, so I can tag you back捉” I said.“Then I'm not playing anymore,” Nevaeh replied __2__.“I guess this is one __3__ that people make rules for games,” said Raymond. “We can still play together if we __4__ on the rules with Nevaeh.”“But __5__ are boring. I just want to play!” I decided to try playing without rules.I went on the monkey bars(攀登架) before Amelia went to the end of the bars and we hit each other. She __6__ and refused to play with me.Maybe that's why people need rules. If I used rules, Nevaeh would think the game of tag was __7__. If I waited for my turn on the monkey bars, Amelia would not __8__ me.“Raymond, you're right, rules are __9__. They help keep things correct, safe, and fun,” I said to him __10__. From then on, I learned that we should pay attention to the rules.( )1. A. look for B. talk about C. think of D. run after ( )2. A. politely B. bravely C. excitedly D. unhappily ( )3. A. way B. reason C. answer D. problem ( )4. A. call B. agree C. come D. depend ( )5. A. games B. jobs C. books D. rules( )6. A. cried B. laughed C. enjoyed D. appeared ( )7. A. boring B. easy C. fair D. wrong( )8. A. be strict with B. be angry with C.be worried about D. be proud of( )9. A. difficult B. strange C. important D. traditional ( )10. A. nervously B. luckily C. tiredly D. seriously三、阅读理解(本大题共15小题,每小题2分,共30分)ADo you think your school rules are boring?Take a look at these rules.Interested?Click here to read more.( )1. When did some schools in New Jersey make the rule“no hugging”?A. In 2008.B. In 2010.C. In 2012.D. In 2014.( )2. Where are the students at one Michigan high school asked to keep their books?A. In the lockers.B. In the classrooms.C. In the lunchrooms.D. In teachers' offices. ( )3. Where are NOT mobile phones allowed into class?A. In some schools in Portland.B. In some schools in Florida.C. In some schools in Pennsylvania.D. In some schools in Brooklyn.( )4. What should NOT a student do in the Toronto school?A. Hug with classmates.B. Bring a bag into the classroom.C. Wear boots into class.D. Bring a basketball to school.( )5. Where is the passage from?A. A newspaper.B. A website.C. A speech.D. A diary.BMany parents like setting family rules for their kids. When their kids break the rules,parents will punish them. In fact,when you tell your kids about a new rule,you should tell them what the punishment will be.Punishments should be reasonable. For example,if you find your son smoking,you can limit(限制)his social activities for two weeks,such as stopping him from going to parties or going to the cinema. After the rules are broken,you should punish your kids only in some ways which you have discussed with them. A study finds that the most popular punishment is to limit kids' TV time. It not only makes them pay more attention to study by reducing their time for fun,but also punishes them by making them rethink what they have done wrong.When rules are broken,you may get angry. Punishment is a way to tell your children you are angry,but it's not a very good one. Talking about your angry or sad feelings with your kids can have a better influence on them. When your kids know what they have done has made you sad,they will feel guilty. They will think about if they have done wrong. When they know their actions influence you greatly,they will follow the rules better.Family rules are made to help your kids behave(表现)better. If your rules or ways of punishment make them unhappy or under a lot of stress,are they helpful?( )6. What would the writer advise a father to do if his 14-year-old son smokes?A. Never talk with his son again.B. Limit his son's sleeping time.C. Stop giving his son money.D. Limit his son's social activities.( )7. What does the writer think is better for parents when they get angry?A. Leaving kids alone.B. Talking with kids.C. Punishing kids.D. Making more rules.( )8. What does the underlined word “guilty” mean in the third paragraph?A. Excited.B. Sorry.C. Angry.D. Bored.( )9. According to the passage,why do people set family rules?A. To make the kids unhappy.B. To help the kids behave better.C. To give the kids punishment.D. To give the kids much stress.( )10. What does this passage mainly talk about?A. How to punish kids reasonably when they break rules.B. How to make more strict family rules.C. What punishment the kids will get if they break rules.D. Whether punishment is necessary at home or not.C配对阅读。
Unit 7【单元测试基础卷】-九年级英语全一册单元速记巧练(人教版)(原卷版)

Our classroom mustevery day by us.
28.Students can’t take magazines out of the reading room without permission.(改为被动语态)
Magazinesout of the reading room without permission by students..
29.We must take good care of the old people in our country.(改为被动语态)
The old people mustgood care of in our country.
When I was seven coughing(bad), she said no ice-cream for me.
But I talkedloudly, “I should be allowed to eat some! Give it to me now!”
When I was nine watching scary movies, she said it’d give me adreams.
Sandy: I’m going to bring my new camera(take) lots of photos!
Wu Lan: Oh, no. Mr. Smith says we must not take photos. It’s not allowed in the museum.
Sandy: That’s too bad! Do you think we mbe allowed to take photos if we don’t use a flash?
nunit测试报告

Nunit测试报告NUnit是一个用于测试.NET代码的单元测试框架,它提供了一种简单且灵活的方式来进行单元测试。
本文将介绍如何创建并使用NUnit测试报告。
步骤一:安装NUnit框架首先,我们需要安装NUnit框架。
可以通过NuGet包管理器来安装NUnit。
打开Visual Studio并选择你的项目,在解决方案资源管理器中右键单击项目,选择“管理NuGet程序包”。
在NuGet包管理器中搜索“NUnit”,然后安装最新版本的NUnit框架。
步骤二:创建测试类在项目中创建一个新的测试类,该类将用于定义测试方法。
测试类应该以“Test”结尾,以便与其他类进行区分。
以下是一个示例测试类的代码:using NUnit.Framework;[TestFixture]public class MyTests{[Test]public void TestAddition(){int result = Calculator.Add(2, 3);Assert.AreEqual(5, result);}}在上面的示例中,我们定义了一个名为“MyTests”的测试类,并在其中定义了一个名为“TestAddition”的测试方法。
在测试方法中,我们调用了一个名为“Calculator.Add”的方法来执行加法运算,并使用断言来验证结果是否符合预期。
步骤三:运行测试完成测试类的编写后,我们可以使用NUnit Test Runner来运行测试。
在Visual Studio中,选择“测试”菜单,然后选择“运行”>“所有测试”。
这将会运行项目中的所有测试方法,并生成测试报告。
步骤四:查看测试报告当测试完成后,我们可以查看生成的测试报告。
NUnit会生成一个包含测试结果的HTML文件。
打开该HTML文件,你将看到一个详细的测试报告,其中包含测试的结果、通过的测试用例、失败的测试用例以及其他有关测试的统计信息。
结论通过使用NUnit,我们可以轻松地进行单元测试,并生成详细的测试报告。
Unit7单元测试

2019-2020学年第二学期四年级英语下册Unit7单元测试卷听力部分(40分)I.听录音,选出你所听到的单词。
(10分)( )1. A. ill B. hill C. still ( )2. A. right B. night C. tiger ( )3. A. Mrs B. Mr C. Miss ( )4. A. dear B. hair C. pear ( )5. A. fly B. try C. hey ( )6. A. bed B. Ken C. ten ( )7. A. come B. home C. some ( )8. A. no B. not C. hot ( )9. A. ball B. tall C. all ( )10. A. mouse B. nose C. rose II.听录音,给下列图片标序号。
(8分)( ) ( ) ( ) ( )( ) ( ) ( ) ( ) III.听录音,选出正确的答句。
(12分)( )1. A. It ’s a hot dog. B. I ’m hot. C. Yes, it is. ( )2. A. Yes, I am. B. Yes, they are. C. No, it isn ’t. ( )3. A. Good evening. B. Good night. C. Good idea. ( )4. A. Yes, you ’ re right. B. Well done. C. All right.( )5. A. Here ’s a jacket. B. Here ’s a cake. C. Here ’s some milk. ( )6. A. I ’m thirsty. B.OK. C. All right. IV .听录音,将对话补充完整。
(10分)1. A: We ’re so _______. B: Here ’s _______ _______for you.A: Thank you.2. A: Helen _______ so _______. B: She can ’t _______ now.学校 _______________________ 班级 ______________ 姓名 ____________________考场 ____________ 座位号_____________密 封 线A:What a _______! I _______ _______ invite(邀请) her to a party.B: I’m sorry. She _______ go today.笔试部分(60分)I.判断下列单词划线字母发音是否相同,相同写S,不同写D。
Unit 7 单元测试人教版九年级英语全册

Unit 7 Teenagers should be allowed to choose their own clothes.单元检测题一、用所给单词的适当形式填空。
1.Phototaking isn’t ______________ (allow) in the museum.2.He is too young ______________ (clean) the room.3.I have made many______________ (decide).4.I can learn a lot from ______________ (do) my homework.5.Parents should give their children chances______________ (do) what they can.6.I am______________ (excite) about going shopping.7.He is allowed ______________ (watch) TV after supper.8.I regret not______________ (listen) to Mom.9.I need to spend more time______________ (play) on the playground.10. It is hard ______________ (keep) reading English every day.11. She practiced______________(play) the piano when she was young.12. He managed ______________(do) it and in the end he succeeded.13. No matter how many______________(difficult) we have, I believe all problems can be solved.14.If you work hard, you won’t worry about your ______________(succeed).15.I have nothing against______________(sing) loudly.16.I think I should be allowed to make this______________(choose) myself.17. We should encourage the children______________(eat)more vegetables.18. They seem _______________(go )on vacation today.19. I______________(allow)to take the test later. I felt happy.20. You need _____________(practice) speaking English with your foreign teacher.21. Some toys______________(buy)as a presents for these children last Monday.22. Last night, we had our computer ____________.(repair)23. I’m worrie d about the______________(safe) of the product.24. When I realized my mistake, I______________(regret) not taking my mother’s advice.25. Teens should be______________(educate) to be polite to the elderly.26.______________(smoke) is not allowed in this area.27. Everyone needs a better _______________(educate) if he wants a good job.28.The classroom must be ___________(keep) clean every day.29. The trees can stop the wind and sand from ____________(moving) to the city.30. Don’t feel ____________(easy). Everything will be OK.31. After working for a long time, I feel _____________.(sleep)二、根据汉语提示,翻译短语,注意适当形式的变化。
2016七年级英语上册Module7Computers单元练习新版外研版

Module7 Computers 单元练习一、听力 ( 听力 ) (共 15 小题;共15 分)Ⅰ .听句子,选择最正确答语。
每个句子读一遍。
(5分)1. A. Yes,I'll take it.B.Not until the snow stops.C.Yes,I really do.2. A. I'd like to make a reservation for next Monday.B.Yes,you may give me a hand.C.I went shopping by bus.3. A. Sorry to hear that.B.Enjoy yourselves.C.I will do my homework.4. A. Yes,I'd like to.B.Yes,please.C.No,thank you very much.5. A. It's very interesting.B.I don't know.C.Yes,it's nice.Ⅱ .听对话,选择正确答案。
每组对话读两遍。
(5分)6. What is the man?A. A teacher.B. An actor.7. How was her summer camp?A. It wasn't exciting.B. It was relaxing.8. Where did the woman go just now?A. The museum.B. The library.9. How long has the woman kept the bike?A. Two years.B. Six years.10. What are they going to do this afternoon?A. See a film.B. Watch a match.Ⅲ .听长对话,选择最正确答案。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
• • • • • • • • • • • • • • • • • • • • • • • • • •
public void testMinus() { int expected=21474646; int actual=b.minus(); assertEquals(expected, actual); } public void testMultiply() { int expected=0; int actual=c.multiply(); assertEquals(expected, actual); } public void testDivide() { int expected=0; int actual=d.divide(); assertEquals(expected,actual); } public static Test suite(){ TestSuite suite = new TestSuite("Running all tests."); //加入测试类中的部分测试方法 ; suite.addTest(new ComputerTest("testAdd")); suite.addTest(new ComputerTest("testMinus")); //加入测试类中的所有测试方法 ; //suite.addTestSuite(ComputerTest.class); return suite; } }
• 3、 JUnit的集成模式 、 的集成模式
• public static Test suite(){
• TestSuite suite = new TestSuite("Running all tests."); • • • • • • • • } //加入测试类中的部分测试方法 ; suite.addTest(new ComputerTest("testAdd")); suite.addTest(new ComputerTest("testMinus")); //加入测试类中的所有测试方法 ; //suite.addTestSuite(ComputerTest.class); return suite;
• • • • • • • • • • • • • • • • • •
public int divide() { if(b!=0) return a/b; else return 0; } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Computer c=new Computer(10,5); System.out.println(c.add()); System.out.println(c.minus()); System.out.println(c.multiply()); System.out.println(c.divide()); }
• • • • • • • • • • • • • • • • • • •
public void testMinus() { int expected=5; int actual=c.minus(); assertEquals(expected, actual); //fail("Not yet implemented"); } public void testMultiply() { int expected=50; int actual=c.multiply(); assertEquals(expected, actual); //fail("Not yet implemented"); } public void testDivide() { int expected=2; int actual=c.divide(); assertEquals(expected,actual); //fail("Not yet implemented"); } }
• • • • • • • • • • • • • • • • • • • • •
public class Computer { private int a; private int b; public Computer(int x ,int y) { a=x; b=y; } public int add() { return a+b; } public int minus() { return a-b; } public int multiply() { return a * b; } }
7.2 NUnit
1、测试环境的搭建 2、测试项目的建立. (1)测试项目要添加引用 (2)如果使用工具NUnit.exe.要在测试 项目属性,调试中,添加路径。 (3)测试程序中导入using NUnit.Framwork
ipse\plugins中加入JUnit3插件包 org.junit_3.8.2.v20080602-1318,或者 org.junit4_4.3.1 org.junit4_4.3.1。 在项目类库中增加JUnit 3类库。 2、测试项目的建立. (1)新建java项目,完成Computer类; (2)新建测试类。 (3)运行测试JUnit Test
1、测试步骤 1)静态测试 2)动态测试 2、白盒测试工作 1)设计测试用例 2)设计测试类模块 3)跟踪调试
3、单元测试的设计方案 1)单元测试环境配置 2)程序代码测试 静态测试考虑的方面P236 动态测试考虑的方面P237
7.1.3 单元测试的自动化测试构建
单元测试的自动化构建主要从以下几个方面考虑 1)根据目标和内容确定哪些方面的测试工作可以 自动化 2)对自动化测试的功能、成本、效率进行评估 3)针对人工测试或测试效率较低的测试部分应考 3 虑实施自动化测试 4)设计自动化测试的架构方案及实施细节 5)正确选择单元测试用具 6)执行所制定的单元自动化测试策略的各项具体 步骤和过程
• • • • • • • • • • • • • • • • • • • • •
public void testAdd() { int expected=3; int actual=a.add(); Assert.assertEquals(expected, actual); } public void testMinus() { int expected=21474646; int actual=b.minus(); assertEquals(expected, actual); } public void testMultiply() { int expected=0; int actual=c.multiply(); assertEquals(expected, actual); } public void testDivide() { int expected=0; int actual=d.divide(); assertEquals(expected,actual); } }
• • • • • • • • • • • • • • • • •
import junit.framework.TestCase; public class ComputerTest extends TestCase { Computer c=null; public ComputerTest() { c=new Computer(10,5); } public void testComputer() { //fail("Not yet implemented"); } public void testAdd() { int expected=15; int actual=c.add(); assertEquals(expected, actual); //fail("Not yet implemented"); } }
import junit.framework.*; public class ComputerTest extends TestCase { private Computer a; private Computer b; private Computer c; private Computer d; public void setUp() { a=new Computer(1,2); b=new Computer(21474647,1); c=new Computer(2,0); d=new Computer(2,0); System.out.println("hello"); } public void tearDown() { System.out.println("welcome"); }
第7章 软件项目的单元测试
7.1软件项目的单元测试 7.1软件项目的单元测试 7.2 NUnit 7.3 Junit
7.1软件项目的单元测试 7.1软件项目的单元测试
• 单元测试概念:针对程序模块,进行正确性检验 的测试,它包括单元模块(程序)的的功能体现 和结构的分析,单元程序的质量检测,以及在必 要时的性能测试等等。 • 单元测试目的:发现程序模块内部可能存在的各 种差错,主要从程序的内部结构出发去考虑测试 的策略,设计测试的架构,运用各种测试方法和 自动化技术,进行测试用例的设计并执行测试, 分析程序质量,用于检测单元模块程序中的缺陷 或bug的过程。
7.1.1单元测试的范围及内容 7.1.1单元测试的范围及内容
合格的程序代码应具有的性质(根据优先级排 列):正确性,清晰性,规范性,一致性和高效 性 单元测试的范围及内容 (1)功能检查 (2)模块接口测试 (3)局部数据结构测试 (4)路径覆盖测试 (5)错误处理测试 (6)程序规范性测试