Harbin Institute of Technology
Department of Computing / School of Software
2022 Fall Semester
2020 undergraduate course "Software Process and Tools" ( 3.0 credits)
homework report
Assignment 3 : Software Test Report
Name |
student ID |
Contact information |
Shi Zhuofan |
120L021011 |
[email protected]/18974330318 |
(1) Learn the basic methods of software testing;
(2) Practice the basic process of software testing;
(3) Master the methods of unit testing and integration testing;
(4) Master the basic methods of white box testing and black box testing;
(5) Learn the basic evaluation and user experience of UI;
(6) The homework requirements are mainly completed by individuals independently.
X64 CPU; 2GHz; 2G RAM; 256GHD Disk or more
Windows7/10 64-bit or above; VirtualBox/Vmware 11 or above; Ubuntu 16.04 LTS 64-bit/Ubuntu Kylin 64-bit or above;
IDEA
- The IDE is idea, install idea and configure jdk11. , the idea adopts the professional version 2021.2.3. About the 30-day trial limit, I spent a while groping for this problem I encountered before the holiday, and finally adopted a patch cracking trial
- Download JDK11 in IDEA and configure JDK11
- select program
Software Construction Lab3---Voting System Partial Code
- hardware environment
X64 CPU; 2GHz; 2G RAM; 256GHD Disk or more
- Software Environment
Windows7/10 64-bit or above; VirtualBox/Vmware 11 or above; Ubuntu 16.04 LTS 64-bit/Ubuntu Kylin 64-bit or above;
- browser
Google Chrome
- web proxy
EasyConnect school intranet vpn
- Select system
Harbin Institute of Technology unified identity authentication, Harbin Institute of Technology today
http://ids-hit-edu-cn-s.ivpn.hit.edu.cn/
- Windows10 system
- Off-campus network, use EasyConnect as VPN to convert to campus network
- Google Chrome
- Download and install EasyConnect
- Enter i.hit.edu.cn
- Login Student ID and Password
- Successfully connected to the campus network VPN
3.1.1.1 Test object
source code
- //immutable
- public class VoteType {
- // key is the option name, value is the score corresponding to the option name
- private Map<String, Integer> options = new HashMap<>();
- // Rep Invariants
- // The option name key cannot be "", and spaces are not allowed
- // The number of options.size() options needs to be >=2
- // Abstract Function
- // AF(String,Integer)-> Option where key is the option name and value is the score corresponding to the option name
- // Safety from Rep Exposure
- // all data fields are private
- // Use Collections.unmodifiableMap() to convert to an immutable type and return it to the outside
- /**
- *
- * @param options voteType corresponding option name and score
- */
- public VoteType(Map<String,Integer> options) {
- this.options=new HashMap<>(options);
- checkRep();
- }
flow chart
According to the incoming Map, create a voting type object
Figure 3.1.1.1 Flowchart
3.1.1.2 Test case design
Classification |
rules |
sample |
|
There are no voting options |
blank |
Null |
|
Voting options exist |
Key meets the conditions |
options2.put(" Like ", 2); options2.put(" Don't like ",0); options2.put(" It doesn't matter ",1); |
|
Key does not meet the conditions |
options3.put(" I like it very much ", 2); options3.put(" ",0); options3.put(" Don't care ", 1); |
3.1.1.3 Test process and results
Test steps:
- Stub program creation options
- Stub program given options variable
- Use junit to judge
For VoteType(Map<String,Integer> options)
1. There is no voting option
2. Voting option exists
2.1Key is eligible
2.2 Key does not meet the conditions
result:
3.1.1.4 Compilation of Driver or Stub program
- /**
- * for VoteType(Map<String,Integer> options)
- * 1. There is no voting option
- * 2. Voting option exists
- * 2.1Key is eligible
- * 2.2Key is not eligible
- */
- @Test
- public void VoteTypeTest_NotRegex()
- {
- Map<String, Integer> options = new HashMap<>();
- VoteType voteType = new VoteType(options);
- assertEquals(options,voteType.getOptions());
- Map<String, Integer> options2 = new HashMap<>();
- options2.put( " like" , 2 );
- options2.put( " Dislike" , 0 );
- options2.put( " Don't care" , 1 );
- VoteType voteType2 = new VoteType(options2);
- assertEquals(options2,voteType2.getOptions());
- // Map<String, Integer> options3 = new HashMap<>();
- // options3.put(" I really like it", 2);
- // options3.put(" ",0);
- // options3.put(" Don't care", 1);
- // VoteType voteType3 = new VoteType(options3);
- // assertFalse(false,voteType3.getOptions());
- }
3.1.2.1 Test object
source code
- public VoteType(String regex) throws IllegalArgumentException{
- // The parameter of split is a regular expression, '|' needs to be escaped
- String[] inputOptions = regex.split("\\|");
- // get "likes" (2)
- // or get "support"
- if(inputOptions.length < 2) {
- throw new IllegalArgumentException( " Illegal input: less than two options" );
- }
- Pattern regexWithNum = Pattern.compile("\"(\\S+)\"\\(([-]?\\d+)\\)");
- Pattern regexWithoutNum = Pattern.compile("\"(\\S+)\"");
- int unMatchFlag= 0 ; // Number of mismatches
- // first try to match the pattern with numbers
- for (String option : inputOptions) {
- Matcher m = regexWithNum.matcher(option);
- if(!m.matches())
- {
- unMatchFlag++; // If the current does not match, the number of mismatches +1
- break;
- }
- if (m.group(1).length() > 5)
- throw new IllegalArgumentException( " The length of the option name exceeds 5" );
- options.put(m.group(1), Integer.valueOf(m.group(2)));
- }
- if(unMatchFlag==0)
- {
- checkRep();
- return;
- }
- // match equal weight format without numbers
- for (String option : inputOptions) {
- Matcher m = regexWithoutNum.matcher(option);
- if(!m.matches())
- {
- unMatchFlag++; // If the current does not match, the number of mismatches +1
- break;
- }
- if (m.group(1).length() > 5)
- throw new IllegalArgumentException( " The length of the option name exceeds 5" );
- options.put(m.group(1), 1);
- }
- if (unMatchFlag== 2 ) // Represents no match
- throw new IllegalArgumentException( " Neither case matches" );
- checkRep();
- }
flow chart
Create a voting type object based on a string that satisfies specific grammar rules
@param regex A string containing vote type information following a specific syntax (to be considered in Task 12)
The syntax rules for this string are as follows:
// "like" (2) | "dislike" (0) | "don't care" (1)
// Among them, the text part enclosed in double quotes is a voting option, the length of which does not exceed 5, which does not
// Spaces are allowed; the number enclosed in parentheses is the score corresponding to the voting option, which can be a positive integer, 0
// Or negative integers, no decimals, positive integers do not need to use "+", but negative integers need to use "-"; different
// The voting options are separated by "|".
// can also be used in the following form:
// "for" | "against" | "abstain"
// Compared to the example above, the difference is that there are no fractions. This situation shows that the weight of each voting option is the same
Figure 3.1.1.1 Flowchart
3.1.2.2 Test case design
Classification |
rules |
sample |
matches a numeric pattern |
Does not contain negative numbers |
" Like "(2)|" Dislike "(0)|" Don't care "(1) |
Contains negative numbers |
" Like "(-2)|" Dislike "(0)|" Don't care "(1) |
|
match no digit pattern |
No more than 5 lengths |
" Support "|" Against "|" Abstain " |
more than 5 lengths |
" Support "|" Against "|" Abstain "|" Super Support "|" Super Abstain "|" Super Super Support " |
|
Can't match normal pattern |
" Support (1)"|" Against "|" Abstain " |
3.1.2.3 Test process and results
Test steps:
- Stub program creation options
- Stub program given options variable
- Use junit to judge
Test success:
1. Test with numbers
1.1 does not contain negative numbers
1.2 with negative numbers
2. Test without numbers
The test throws an exception:
1, more than 5 lengths
2. The format is wrong
result:
3.1.2.4 Compilation of Driver or Stub program
- /**
- * for VoteType(String regex)
- * test successful:
- * 1. Test with numbers
- * 1.1 does not contain negative numbers
- * 1.2 includes negative numbers
- * 2. Test without numbers
- * The test throws an exception:
- * 1 , more than 5 lengths
- * 2. The format is wrong
- */
- @Test
- public void VoteTypeTest_regex()
- {
- //" Like"(2)|"Dislike"(0)|"Don't care"(1)
- Map<String, Integer> options = new HashMap<>();
- options.put( " like" , 2 );
- options.put( " Dislike" , 0 );
- options.put( " Don't care" , 1 );
- VoteType voteType = new VoteType( "\" like\"(2)|\"dislike\"(0)|\"doesn't matter\"(1)" );
- assertEquals(options,voteType.getOptions());
- //" Like"(-2)|"Dislike"(0)|"Don't care"(1)
- Map<String, Integer> options3 = new HashMap<>();
- options3.put( " Like" , -2 );
- options3.put( " Dislike" , 0 );
- options3.put( " Don't care" , 1 );
- VoteType voteType3 = new VoteType( "\" like\"(-2)|\"dislike\"(0)|\"doesn't matter\"(1)" );
- assertEquals(options3,voteType3.getOptions());
- //" Support"|"Against"|"Abstain"
- // No score defaults to 1
- Map<String, Integer> options2 = new HashMap<>();
- options2.put( " support" , 1 );
- options2.put( " oppose" , 1 );
- options2.put( " abstain" , 1 );
- VoteType voteType2 = new VoteType( "\" Support\"|\"Against\"|\"Abstain\"" );
- assertEquals(options2,voteType2.getOptions());
- assertThrows(IllegalArgumentException.class,()-> new VoteType( "\" Super support\"|\"Against\"|\"Abstention\"" ), " The length of the option name exceeds 5" );
- assertThrows(IllegalArgumentException.class,()-> new VoteType( "\" support\"(1)|\"against\"|\"abstain\"" ), " neither case matches" );
- }
3.1.3.1 Test object
source code
- /**
- * Responsible for checking the validity of the ballot and marking it in addVote
- * @param vote vote
- * @param voter _
- */
- public void checkVote(Vote<C> vote,Voter voter)
- {
- Set<VoteItem<C>> voteItems = vote.getVoteItems();
- for (VoteItem<C> voteItem : voteItems) {
- if(!candidates.contains(voteItem.getCandidate()))
- {
- voteIsLegal.put(vote, false ); // Includes candidates who are not in this voting
- return;
- }
- if(!voteType.checkLegality(voteItem.getVoteValue()))
- {
- voteIsLegal.put(vote, false ); // An option value that is not allowed in this vote appears in a ballot
- return;
- }
- for (VoteItem<C> voteItem2 : voteItems)
- {
- if(voteItem2!=voteItem && voteItem2.getCandidate().equals(voteItem.getCandidate()))
- {
- voteIsLegal.put(vote, false ); // There are multiple votes for the same candidate in one ballot
- return;
- }
- }
- }
- for (C candidate : candidates) {
- if(!vote.candidateIncluded(candidate))
- {
- voteIsLegal.put(vote, false ); // A ballot does not contain all the candidates in this voting activity
- return;
- }
- }
- // If there is no exception
- voteIsLegal.put(vote, true ); // Identified as legal
- }
flow chart:
Figure 3.1.3.2.1 Flowchart
3.1.3.2 Test case design
checkVote test
Four Tests for Sharing Illegal Ballots
Illegal ballots:
One ballot does not include all candidates in the poll
A ballot includes candidates who are not in the poll
An option value that is not allowed for this vote appears in a ballot
Multiple votes for the same candidate in one ballot
Candidate candidate1.candidate2, candidate3, candidate4
Voter vr1, ballot is empty
Voter vr2, candidate5, candidate1, candidate2, candidate3 in the ballot
Voter vr3, there are candidate1.candidate2, candidate3, and candidate4 in the ballot, but the option value "like" that is not allowed in this voting appears
Voter vr3, there are candidate1.candidate2, candidate5, candidate4 in the ballot
Voter vr4, there are candidate1.candidate2, candidate3, candidate5 in the ballot
Classification |
rules |
sample |
0 cycles |
Jump directly from loop entry to loop exit |
Voter vr1, ballot is empty |
1 cycle |
Find errors in loop initialization |
Voter vr2, candidate5, candidate1, candidate2, candidate3 in the ballot |
2 cycles |
Check for bugs that can only be exposed when looping multiple times |
Voter vr3, there are candidate1.candidate2, candidate3, and candidate4 in the ballot, but the option value "like" that is not allowed in this voting appears |
m cycles |
At this time, m<n is also an error that can only be exposed when checking multiple cycles |
Voter vr3, there are candidate1.candidate2, candidate5, candidate4 in the ballot |
Maximum number of cycles |
Voter vr4, there are candidate1.candidate2, candidate3, candidate5 in the ballot |
3.1.3.3 Test process and results
Test steps:
Candidate candidate1.candidate2, candidate3, candidate4
Voter vr1, ballot is empty
Voter vr2, candidate5, candidate1, candidate2, candidate3 in the ballot
Voter vr3, there are candidate1.candidate2, candidate3, and candidate4 in the ballot, but the option value "like" that is not allowed in this voting appears
Voter vr3, there are candidate1.candidate2, candidate5, candidate4 in the ballot
Voter vr4, there are candidate1.candidate2, candidate3, candidate5 in the ballot
- create voter
- set voter weight
- Set poll type
- create candidates
- create voting item
- create poll
- Create a poll
- update voter vote
result:
3.1.3.4 Compilation of Driver or Stub program
- /**
- * is the second abnormal condition detected by statisticTest:
- * ( also a test for checkVote)
- * Four tests sharing illegal ballots
- * * Illegal ballot case
- * * ? A ballot does not include all candidates in this poll
- * * ? A ballot contains candidates who are not in this poll
- * * ? An option value that is not allowed for this vote appears in a ballot
- * * ? Multiple votes for the same candidate in one ballot
- * Specific test example:
- * candidate candidate1.candidate2, candidate3, candidate4
- * voter vr1, ballot is empty
- * Voter vr2, candidate5, candidate1, candidate2, candidate3 in the ballot
- * Voter vr3, there are candidate1.candidate2, candidate3, and candidate4 in the ballot, but the option value "like" that is not allowed in this voting appears
- * Voter vr3, there are candidate1.candidate2, candidate5, candidate4 in the ballot
- * Voter vr4, there are candidate1.candidate2, candidate3, candidate5 in the ballot
- */
- @Test
- void checkVote_statistics_BuHeFaTest() {
- // Create 2 voters
- Voter vr1 = new Voter("v1");
- Voter vr2 = new Voter("v2");
- Voter vr3 = new Voter("v3");
- Voter vr4 = new Voter("v4");
- // Set the weight of 2 voters
- Map<Voter, Double> weightedVoters = new HashMap<>();
- weightedVoters.put(vr1, 1.0);
- weightedVoters.put(vr2, 1.0);
- weightedVoters.put(vr3, 1.0);
- weightedVoters.put(vr4, 1.0);
- / / Set the voting type
- Map<String, Integer> types = new HashMap<>();
- types.put("Support", 1);
- types.put("Oppose", -1);
- types.put("Waive", 0);
- VoteType voteType = new VoteType(types);
- // Create a candidate object: Candidate
- Person p1 = new Person("candidate1", 19);
- Person p2 = new Person("candidate2", 20);
- Person p3 = new Person("candidate3", 20);
- ArrayList<Person> candidates = new ArrayList<>();
- candidates.add(p1);
- candidates.add(p2);
- // Create voting items, the first three are voting items of voter vr1 for three candidates, and the last three are voting items of vr2
- VoteItem<Person> vi11 = new VoteItem<>(p1, "Support");
- Set<VoteItem<Person>> voteItems1 = new HashSet<>();
- voteItems1.add(vi11);
- VoteItem<Person> vi21 = new VoteItem<>(p1, "Oppose");
- VoteItem<Person> vi22 = new VoteItem<>(p3, "Waive");
- Set<VoteItem<Person>> voteItems2 = new HashSet<>();
- voteItems2.add(vi21);
- voteItems2.add(vi22);
- VoteItem<Person> vi31 = new VoteItem<>(p1, "Oppose");
- VoteItem<Person> vi32 = new VoteItem<>(p2, "like");
- Set<VoteItem<Person>> voteItems3 = new HashSet<>();
- voteItems3.add(vi31);
- voteItems3.add(vi32);
- VoteItem<Person> vi41 = new VoteItem<>(p1, "Support");
- VoteItem<Person> vi42 = new VoteItem<>(p1, "Oppose");
- Set<VoteItem<Person>> voteItems4 = new HashSet<>();
- voteItems4.add(vi41);
- voteItems4.add(vi42);
- // Create votes for 2 voters vr1 and vr2
- Vote<Person> rv1 = new Vote<Person>(voteItems1, new GregorianCalendar(2019, 6, 14, 16, 15, 30));
- Vote<Person> rv2 = new Vote<Person>(voteItems2, new GregorianCalendar(2019, 6, 14, 16, 15, 30));
- Vote<Person> rv3 = new Vote<Person>(voteItems3, new GregorianCalendar(2019, 6, 14, 16, 15, 30));
- Vote<Person> rv4 = new Vote<Person>(voteItems4, new GregorianCalendar(2019, 6, 14, 16, 15, 30));
- // System.out.println("rv1 = " + rv1);
- // System.out.println("rv2 = " + rv2);
- // Create poll event
- GeneralPollImpl<Person> poll= new GeneralPollImpl<Person>();
- // Set the basic information of voting: name, date, voting type, number of votes
- String name = " Representative Election" ;
- GregorianCalendar date = new GregorianCalendar(2019, 6, 14, 16, 15, 30);
- int quantity = 1;
- poll.setInfo(name, date, voteType, quantity);
- // Add voters and their weight
- poll.addVoters(weightedVoters);
- poll.addCandidates(candidates);
- // Increase the votes of three voters
- poll.addVote(rv1, vr1);
- poll.addVote(rv2, vr2);
- poll.addVote(rv3, vr3);
- poll.addVote(rv4, vr4);
- GeneralPollImpl election = poll;
- Map<Vote<Person>, Boolean> voteIsLegal = election.getVoteIsLegal();
- for (Map.Entry<Vote<Person>, Boolean> voteBooleanEntry : voteIsLegal.entrySet()) {
- Boolean isLegal = voteBooleanEntry.getValue();
- assertEquals(false, isLegal);
- }
- }
-
- Integration /system testing
http://i-hit-edu-cn.ivpn.hit.edu.cn:1080/index#/app/home/index
-
-
- Part of the functional module test of the school's unified identity authentication system for undergraduates
-
3.2.1.1 Test case design
Unified identity authentication system for undergraduates
test sample |
expected outcome |
Final Results |
Test for blank username and password inputs |
Prompt for blank input |
√ |
Test blank password input |
Prompt for blank password input |
√ |
Test correct user name and password input login |
Login successfully, jump to the home page |
√ |
Test Harbin Institute of Technology APP scan code login |
Login successfully, jump to the home page |
√ |
Test QQ login |
Login successfully, jump to the home page |
× Cannot log in with qq |
Test WeChat login |
Login successfully, jump to the home page |
√ |
Password-free login within one week of testing |
You can successfully log in without password within a week, and jump to the home page |
×Unable to avoid password within a week |
Test Forgot Password Retrieve Password |
Password retrieved successfully |
√ |
Test account activation function |
Jump to the account activation page to complete the function |
√ |
Test login page help documentation |
The documentation can explain most of the problems when logging in |
√ |
3.2.1.2 Test process and results
- Test for blank username and password inputs
Result: prompt please enter username
Meet expectations√
- Test blank password input
Result: prompt please enter password
Meet expectations√
- Test correct user name and password input login
Result: Successful login and jump to the home page
Meet expectations√
- Test Harbin Institute of Technology APP scan code login
Result: The code scanning box pops up and you can finally log in successfully
Meet expectations√
- Test QQ login
Result: Failed, calling QQ login may have some bugs that have not been resolved in the future
Did not meet expectations×
- Test WeChat login
Result: The code scanning box pops up and you can finally log in successfully
Meet expectations√
- Password-free login within one week of testing
Result: If you have not logged in without password within a week, you will be prompted to log in again before the week is over
Did not meet expectations×
- Test Forgot Password Retrieve Password
Result: Jump to the forgotten password page successfully, and you can try to change the password
Meet expectations√
- Test account activation function
Result: Jump to the account activation page successfully, and the account can be activated
Meet expectations√
- Test login page help documentation
Result: successfully jump to the help document
Meet expectations√
-
-
- UI usability test and evaluation of the school's undergraduate portal platform system
-
3.2.2.1 Test case design
test sample |
expected outcome |
Final Results |
The default value, jump to the default value if the login is successful |
Display the homepage by default |
√ |
Input verification, verify whether the entered student number meets the specifications |
Prompt that the student number does not meet the specifications |
×Unable to prompt the standard format of student number |
System response, quick response after clicking a function |
Quickly jump to a new page |
×Compared to other websites, the speed is slow |
Information feedback, whether to give prompts for deleted school news |
Prompt that the content has been deleted |
√ |
3.2.2.2 Test process and results
- The default value, jump to the default value if the login is successful
Result: If you log in successfully, you will be redirected to the home page
Meet expectations√
- Input verification, verify whether the entered student number meets the specifications
Result: There is no error in the fixed format of the user name, but a simple error in the user name or password
Did not meet expectations×
- System response, quick response after clicking a function
结果:快速点击多个校内新闻,跳转打开速度较慢
不符合预期×
- 信息反馈,对于已经删除的校内新闻是否会给出提示
结果:校内过时新闻会提示访问页面不存在
符合预期√
3.2.2.3 UI可用性即用户体验评价结果
当前效果 |
可以改进为 |
在主页面的动态效果太少,多数是静态效果 |
可以多一点动态新闻图片展示 |
每一条新闻没有评论功能 |
添加评论功能 |
没有快速点开个人常用应用 |
添加某个用户自己最常用的应用列表 |
没有网站指引说明 |
添加网站指引说明 |
主页一大篇幅我的待办功能略显鸡肋 |
可以调整我的待办的位置 |