Unit Testing and Encapsulation 5.1

Source: Internet
Author: User

Test Cases

Test Project Name

Arithmetic Simple test

Test personnel

Feng Meixin, Wu Shu Ting

Date of establishment

April 30, 2015

Functional characteristics

To test this arithmetic.

Black box test:

The main thing is to test the function of the code with input validity in order to understand or use the internal structure and knowledge of the system.

input type

Input data

Expected output

Actual output

Test status

1 Correct values

(3,4,+)

7

7

That's right

2 numeric value with illegal characters

(2,3w,-)

An exception occurred

An exception occurred

That's right

3 Subtraction

(4,2,/)

2

2

That's right

4 Illegal operators

(2,4,G)

Illegal characters

Illegal characters

That's right

5 Division Denominator is 0

(3,0,/)

Prompt appears

The divisor cannot be 0

That's right

White box test:

In the process of designing tests, we test the internal structure of the program, understand the extent of the code, find errors, and reduce the code.

Test Cases

Use case description

Overridden Code

Test results

1 (1,1,-)

Input of numeric values

Calcutest (1-18)

Run successfully without failure

2 (3,5,6)

Illegal operator

On the previous basis in the execution of calculate (14) i.e. (60-77)

Can judge illegal characters

2 (4,5,+)

Whether to run addition

Calculate 17-18 Lines

Run successfully without failure

3 (1,2,-)

Whether to run subtraction

Calculate 19-20 Lines

Run successfully without failure

4 (6,7,*)

Whether to run multiplication

Calculate 21-22 Lines

Run successfully without failure

5 (9,3,/)

Whether to run division

Calculate 22-38 Lines

Run successfully without failure

6 (3,0,/)

The denominator cannot be 0

Calculate division inside (25-30 lines)

Run successfully without failure

7 (2,e,-)

Illegal characters

Input 40-57

The test is correct, but the program is small.

Code Coverage

90D

For the 7th Picture:

Main code in: Small partner Feng Meixin (http://www.cnblogs.com/maxx/)

Simple encapsulation, which reinforces the simplicity of the code

Unit Testing and Encapsulation 5.1

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.