You are on page 1of 4

Homework Assignment 2 (125 Points)

CSE 464, Spring 2022


CIDSE, Arizona State University
Due: By Saturday Feb 14th by 11:59 pm
---------------------------------------------------------------------------------------------------------------------
Introduction: This assignment helps you to reinforce the topics discussed in the class
including
a) Categories of testing and equivalent class testing.
b) Writing Junit test cases for test automation

1. [25 Points] One of functionalities of a compiler is to determine if variable names


are correct. Here is the variable naming convention of Java programming
language.

“Variable names are case-sensitive. A variable's name can be any legal


identifier — an unlimited-length sequence of Unicode letters and digits,
beginning with a letter, the dollar sign "$", or the underscore character "_".
White space is not permitted.
Subsequent characters may be letters, digits, dollar signs, or underscore
characters.”

Also, you can assume that the input domain for this includes any length string
with characters that developers can type using regular windows keyboard.

Source:
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html

Suppose you are using equivalent partitioning technique to testing the variable name
verification module of the Java compiler.

a) Identify equivalent partitions based on the above description


b) Develop test cases in a tabular format given below based on your equivalent
partitions above. Use strong robust form.
Test case # Partition Tested Input(s) Expected output
2.[ 50 Points] Equivalent Partitions: Credit Card Verification Problem

Consider the following program that checks if a credit number is a valid card number.

The last digit of a credit card number is the check digit, which protects againts transaction
errors. The following method is used to veryfy credit card numbers. Follwing steps explains the
algorithm in determining if a credit card number is a valid card.

 Starting from the right most digit, form the sum of every other digit. For example, if the
credit card is number is 3125145643589795 then you form the sum 5+7+8+3+6+4+5+1 = 39

 Double each digit that we have not included in the preceding step. Add all digits of
resulting numbers. For example, with the number given above, doubling the digits
starting with next to last one, yields 18, 18, 10, 8, 10, 2, 4,6. Adding all digits in these
values yield 1+8+1+8+1+0+8+1+0+2+4+6 = 40

 Add sum of the two preceding steps. If the last digit of the result is zero, then the
number is valid number

The program asks the user 16 digit credit card number and the printout if the credit card is valid
or invalid card

a) [20 Pts] How do you test this application using EP technique? Identify your Eps
Write test cases based on your EPs (use strong robust classification). Need to submit EPs
and Test cases in a tabular format for this question.

b) [30 Pts] Develop Junit test cases based on your test cased listed above and test the java
program given (Assignment2.java). This java program has two defects. Identify defects in
this program (If your test cases can catch them, you have developed good set of test cases!).
You can assume that the user will enter a 16-digit number. No need to consider other types
of inputs such as strings, characters …etc.. You need to submit Junit test case file for this
question.

c) [10 Pts] How do you fix the defects in the program? Submit the corrected Java program.
3.[50 Pts] Consider the shape program question from midterm I where you have to test a program
that takes length of four sides and four angles of a quadrilateral (a shape with four sides). Here
is the modified version of the program. Program gives one of the five possible outcomes:
“Square”, “Rectangle”, “Rhombus”, and “other quadrilateral”, “Not a quadrilateral” given four
angles and sides.

Length of Four Sides


Square/Rectangle/Rhom
Shape Determination bus/None of the three
Software types
Sizes of four angles

Square: All four sides are equals and four angles are right angles (90 degree)
Rectangle: Not all four sides are equal, but parallel sides have the same length and angles are
right angles (90 degree)
Rhombus: All four sides are equal with opposite equal acute angles, opposite equal obtuse
angles.
Other quadrilateral: None of the above but four angles add up to 360 and has four sides
Not a quadrilateral: four angles do not add up to 360 (and/or) has less than 4 sides
a) [40 Pts] Identify equivalent partitions to test this application. Write them clearly. Then,
develop test-case to test them. Use strong robust classification. You may need to study the
triangle problem example that we have discussed in the class and use similar approach

b) [10 Pts] Run the Shapes.exe program (This program is tested in windows computers) and
test the program to identify bugs using equivalent partition based test cases. This program
has several bugs (identify at least 4 bugs)

Submission Instructions:
Things to submit:
1. Answers to question 1 part a and b in PDF format. Handwritten is okay if readable
and clear. Name PDF as HW2_Q1.pdf

For question 2:
a. PDF document containing answers to part a.
b. Junit test program (java file) for part b and a PDF document explaining bugs in
the program
c. Corrected java program for part c

Name PDF as HW2_Q2.pdf

For question 3:
a. PDF document containing equivalent partitions and test cases for part (a) and
list of bugs for part (b). Name PDF as HW2_Q3.pdf

How to submit:

Create a zip file that contain all the submission items listed above and submit online to
the blackboard.

NO LATE SUBMISSIONS WILL BE ACCEPTED

You might also like