Software Engineering Practice Job 2

Source: Internet
Author: User

I. Introduction of the topic

Write a program that calculates the frequency of English words for a set of text documents.

Second, the source of GitHub links

Https://github.com/liuxu8257/zuoye2

Third, the design of the module test cases, test results

This implementation has three methods, the three methods were tested:

Three Tests to get the string method in the file:

1     @Test 2 public     void Tsetnullfile () throws ioexception{3         file file =null; 4         Deal dos = new Deal (); 5
   
    string result = dos.getstring (file); 6         assertnull (result); 7     } 8      9     @Test10 public     void Testnocontentfile () throws IOException {11 File         file =new file ("D:/empty.txt");         Deal dos = new Deal ();         String result = dos.getstring (file)         , Assertequals ("", result);     }16     17     @Test18 public     void Testnormalfile () throws IOException {         file file =new file ("D:/normal.txt"); 20         Deal dos = new Deal ();         String result = dos.getstring (file)         , Assertequals ("hello,my name is matin,i am thirty-three years old.", result); (+     }
   
The methods for extracting words are tested as follows:
1     @Test 2 public     void Testtakeword () throws IOException {3         File file =new file ("D:/normal.txt"); 4         Deal D OS = new Deal (); 5         String str = dos.getstring (file), 6         list<string> result = Dos.takeword (str); 7 for         (String show: Result) {8             System.out.print (show); 9         }10     }    

The test prints the result: Hello my name is matin I am thirty three years old

The following tests are done for calculating the word frequency:

1     @Test 2 public     void Testfrequency () {3         list<string> List = new Arraylist<string> (); 4         List.add ("three"); 5         List.add ("three"), 6         list.add ("a"), 7         list.add ("a"), 8         list.add ("three"), 9         list.add (" One "),         List.add (" one "),         Deal dos = new Deal ();         HashMap map = dos.getfrequency (list); 14         the         Iterator iter = Map.entryset (). Iterator (); +         (Iter.hasnext ()) {map.entry Entry             = (map.entry) Iter.next ();             string key = (String) entry.getkey ();             int val = (Integer) entry.getvalue ();             System.out.println (key+ ":" +val);         }22     }

The test prints the result:

Three:3

Two:2

  One:2

  Test results:

  

Iv. problems and solutions, experience.

This homework I learned some of the software testing operations, a preliminary understanding of software testing has stimulated a strong interest in learning will be good to learn such courses

Software Engineering Practice Job 2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.