0% found this document useful (0 votes)
87 views8 pages

Unit Testing Techniques for Mycal Class

This document describes Assignment #2 for a Software Quality Engineering course. It provides code for a calculator class and asks the student to: 1. Select a suitable testing technique like unit testing to test the code using state-based testing. 2. Write test cases using techniques like category-partitioning and decision table testing. 3. Report the code coverage achieved by the test cases. The student provides examples of using state-based testing on the code. They then write test cases using category-partitioning and decision table testing. Finally, the student reports achieving a high level of statement coverage between 80-100% on the different test cases.

Uploaded by

aymal khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views8 pages

Unit Testing Techniques for Mycal Class

This document describes Assignment #2 for a Software Quality Engineering course. It provides code for a calculator class and asks the student to: 1. Select a suitable testing technique like unit testing to test the code using state-based testing. 2. Write test cases using techniques like category-partitioning and decision table testing. 3. Report the code coverage achieved by the test cases. The student provides examples of using state-based testing on the code. They then write test cases using category-partitioning and decision table testing. Finally, the student reports achieving a high level of statement coverage between 80-100% on the different test cases.

Uploaded by

aymal khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ASSIGNMENT#2: [CLO-3]

Aymal Khalid khan


Software
\ Quality Engineering BSE_VI  01-131172-005 Tuesday, May 26, 2020
Aymal Khalid Khan 01-131172-005 BSE_VI

Please make use of the code given below:

Dr. Tamim Iqbal Software Quality Engineering Assignment#2


Aymal Khalid Khan 01-131172-005 BSE_VI

 Questions: 1. please select a suitable testing technique from the


following:
 Unit testing framework to write unit tests for the given code in
MSVS such that they reveal faults using state-machine based
testing method.
Due to Protection levels there are errors in the MSVS.

After doing some changes in the protection level for the code the Result is
the following state machine Diagram

Dr. Tamim Iqbal Software Quality Engineering Assignment#2


Aymal Khalid Khan 01-131172-005 BSE_VI

Unit Test for the Given Code:

 b.

Category-partitioning method to write test cases.


A. Create object with constructor without passing arguments.
B. Call functions with this object.
C. Call Class type method with this object and store it in another object.
D. Create object1 with constructor passing arguments.
E. Call functions with this object1.
F. Call Class type method with this object1 and store it in another object or
the one created before.
Weak Normal Equivalence Test Cases (“Independence of Input Variables”)
Output Inputs
Mycal() Op1=1, Op2=1, Mycal obj = new Mycal()
Constructer Called
Mycal(int 01 , int o2) op1=o1,op2=02, Mycal obj1 = new Mycal(-3,2)
Calculator = “Simple Calculator”
Constructor Called

Dr. Tamim Iqbal Software Quality Engineering Assignment#2


Aymal Khalid Khan 01-131172-005 BSE_VI

myMult(int op1, int op2 , string type) [Link](4,5,”simple calculator”)


return’s op1+op2
myMult(int op1, int op2 , string type) [Link](4,5,” ”)
return’s 0
myDiv(Mycal calc) return calc Obj2=New Mycal().mydiv(obj)

Strong Normal Equivalence Test Cases (“dependence” among the inputs”)


Output Inputs
Mycal() Mycal obj = new Mycal()
Mycal(int 01 , int o2) Mycal obj1 = new Mycal(-335131,+2324)
myMult(int op1, int op2 , string type) [Link](-2314244,+ 122334,” ”)
myMult(int op1, int op2 , string type) [Link](+4333322411569067,”simple
calculator”)
myDiv(Mycal calc) new Mycal().myDiv()

Weak Robust Equivalence Test Cases (invalid input variables are now considered.)

Output Inputs
Mycal() Mycal obj = new Mycal(2341)
Mycal(int 01 , int o2) Mycal obj1 = new Mycal(-
23523414123331,+2398954563524)
myMult(int op1, int op2 , string type) [Link](-2314244,+ 122334,1)
myMult(int op1, int op2 , string type) [Link](+4333322411569067,1.5)

myDiv(Mycal calc) new Mycal().myDiv(obj4)

Strong Robust Equivalence Test Cases (Invalid input variables are now considered.)

Output Inputs
Mycal() Mycal obj = new Mycal(“213”)
Mycal(int 01 , int o2) Mycal obj = new Mycal(-041386234a,””)
myMult(int op1, int op2 , string type) [Link](1.32,53.2,”2..3”)
myMult(int op1, int op2 , string type) [Link](3.243,0.53)
myDiv(Mycal calc) New Mycal().myDiv(“obj4”)

Dr. Tamim Iqbal Software Quality Engineering Assignment#2


Aymal Khalid Khan 01-131172-005 BSE_VI

 Decision table-based testing method to write test cases.


Parameters Object Created Object Created(parameters) myMult mydiv

No parameters
T F F F
Mycal()o2
int o1,int XF T F F
int op1, int op2, string
T T T F
type
Mycal(int
int op1, 01 , int o2)
int op2 X
T T F F
Mycal calc
myMult(int op1 , int X X X
op2 , string type) F T T T
Mycal calc
T T T T
Mycal X X X
mydiv(mycal) T T T F

IMPOSSIBLE X X


Please write test cases and please report coverage with how did
you achieve that.

Test Case Test Test Steps Test Data Expected Actual Results Pass/Fail
ID Scenario Results

TU01 Create 1. Create Obj= new Mycal() Object Object created Pass
object object should be
without without created
parameters parameters
passing passing to
the
constructor

TU02 Create 1. Create Obj1=new Mycal(3,2) Object As Expected Pass

Dr. Tamim Iqbal Software Quality Engineering Assignment#2


Aymal Khalid Khan 01-131172-005 BSE_VI

object with object with should be


parameters parameters created
passing passing to with
the values
constructor assigned

TU03 Call 1 Calls MyMult(2,3,” ”) Should As Expected Pass


myMult function return 0
function 2 Returns 0
with int
Parameters
passed

TU04 Call 1 MyMult MyMult(2,3,”Simple Should Returns 5 Pass


myMult should Calculator”) return 5
function assign
with values
Parameters 2 Must return
passed a value

TU05 Call myDiv 1 Assigns newmyCal().myDiv(Obj1) Should Returns the Pass


with object Values to return the object
passed as the object object
parameter passed
2 Returns
object

Coverage Report:
Almost All the requirements with test case template has been covered. The test cases are
covering the application code given. Every Code in the application is exercised when we run
those test cases as described.

TU01: Number of executed statements= 7, Total number of statements=7


 Statement Coverage: 7/7 = 100%
TU02: Number of executed statements= 7, Total number of statements=7
 Statement Coverage: 7/7 = 100%
TU03: Number of executed statements= 5, Total number of statements=6

Dr. Tamim Iqbal Software Quality Engineering Assignment#2


Aymal Khalid Khan 01-131172-005 BSE_VI

 Statement Coverage: 5/6 = 90%


TU04: Number of executed statements= 4, Total number of statements=6
 Statement Coverage: 4/6 = 80%
TU05: Number of executed statements= 5, Total number of statements=5
 Statement Coverage: 5/5= 100%

Aymal Khalid Khan 01-131172-005


Umar Farooq 01-131172-030
Dr. Tamim Iqbal
Software Quality Engineering

Dr. Tamim Iqbal Software Quality Engineering Assignment#2

You might also like