Pair programming 2-unit test, pair 2-unit test

Source: Internet
Author: User

Pair programming 2-unit test, pair 2-unit test

201421123022 Wang ruofan 201421123026 Ouyang Yong

Code details

 

A. Requirement Analysis:

A. Test the addition, subtraction, multiplication, division, and Division functions.

B. enter invalid characters for testing

C. test if the value is out of range

D. Test the result except 0

 

B. design the test framework and simulate the test data (view code)

1. Test the addition, subtraction, multiplication, division, and Division functions.

@Test    public void testAdd() {          calc.add(5,8);          assertEquals(13, Integer.parseInt(calc.getResult()));    }     @Test    public void testSubstract() {        calc.substract(5,8);         assertEquals(-3, Integer.parseInt(calc.getResult()));    }     @Test    public void testMultiply() {         calc.multiply(5,8);         assertEquals(40, Integer.parseInt(calc.getResult()));    }     @Test    public void testDivide() {         calc.divide(5,8);         assertEquals(String.valueOf("5/8"), calc.getResult());    }     @Test    public void testAdd2() {        calc.add2(2,4,2,3);         assertEquals(String.valueOf("7/6"), calc.getResult());    }     @Test    public void testSubstract2() {         calc.substract2(2,4,2,3);         assertEquals(String.valueOf("1/-6"), calc.getResult());    }     @Test    public void testMultiply2() {        calc.multiply2(2,4,2,3);         assertEquals(String.valueOf("1/3"), calc.getResult());    }     @Test    public void testDivide2() {        calc.divide2(2,4,2,3);         assertEquals(String.valueOf("3/4"), calc.getResult());    }

This part of function code is not pasted for a long time and will be included in the coding.

 

2. enter invalid characters for testing

@ Testpublic void testPanduanzifu () {// String s = calc. getResult (); calc. panduanzifu ("4/7! # @ $ "); AssertEquals (" input error ", calc. getResult ();} public void panduanzifu (String s) // judge the input character, {char arr [] = s. toCharArray (); for (int I = 0; I <s. length (); I ++) {if (arr [I] <45) | (arr [I]> 58 )) {sum1 = "input error ";}}}

 

  

3. The value is out of range for testing.

@ Testpublic void testRange () {calc. range (11,3); assertEquals ("outrange", calc. getResult ();} public void range (int x, int y) // range judgment {if (x <0 | x> 10) | (y <0 | y> 10) sum1 = "outrange ";}

 

4. Test results except 0

@ Testpublic void testZero () {calc. zero ("4/0"); assertEquals ("zero error", calc. getResult ();} public void zero (String s) {// The result except 0 error s = s. substring (s. length ()-2, s. length (); if (s. equals ("/0") {sum1 = "zero error ";}}

 

Result

If the result sum1 returned from the test data is the same as the preset result, the operation is correct.

 

Summary and feelings

In this pair programming 2-unit test, I always felt that nothing would happen, as if I had entered a blind zone of knowledge. At the beginning, I was confused and did not even know what to do. I had to finish the task slowly through the words, deeds, and online search of my teammates. Testing is very important for a program. A system testing will make the program running safer and reduce the occurrence of bugs. After this assignment, I also found that my programming skills were insufficient, and my knowledge was incomplete. I still needed to improve my skills.

Hamburger rating

 Put a piece of bread first: what two people have in common has been said last time, this is the second cooperation, the two people are more tacit;

Put meat and condiments on it: the Knowledge System of teammates is relatively complete. This time I was overwhelmed and helped a lot. Although the roles of the two were exchanged, but more is the dedication of rufan;

Put it on the bread: the second cooperation was more tacit, and the efficiency naturally increased, cheering for the progress of the two people!

 

PSP

PSP2.1

Personal Software Process Stages

Estimated time (h)

Actual time (h)

Planning

Plan

6

5.2

· Estimate

Estimated time required for this task

6

5.2

Development

Development

0.5

0.3

· Analysis

Demand Analysis (including learning new technologies)

0.2

0.2

· Design Spec

Generate design document

0.2

0.1

· Design Review

Design Review

0.1

0.1

· Coding Standard

Code Specification

0.2

0.2

· Design

Specific design

0.5

0.5

· Coding

Code

3

2.5

· Code Review

Code Review

0.5

0.5

· Test

Test (self-test, code modification, and modification submission)

0.3

0.3

Reporting

Report

0.2

0.2

·

Test report

 

 

·

Computing workload

0.1

0.1

·

And propose a process improvement plan

0.2

0.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.