0% found this document useful (0 votes)
11 views7 pages

STAssignment 02

STAssignment-02

Uploaded by

Noor-Ul Ain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

STAssignment 02

STAssignment-02

Uploaded by

Noor-Ul Ain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

Software Testing
Assignment # 02

SUBMITTED TO:
DR. ALI JAVED

SUBMITTED BY:
NOOR-UL-AIN 21-SE-78
HIRA AMJAD 21-SE-90

SECTION:
OMEGA

SOFTWARE ENGINEERING DEPARTMENT


ASSIGNMENT # 02
Q1: Write Junit scripts and perform unit testing of any global application whose code is
available or can be retrieved. Write tests for all units of your selected application.

APPLICATION:
“Java Calculator”

This is a simple calculator application written in the Java programming language. The calculator
application can perform basic arithmetic operations such as addition, subtraction, multiplication,
and division. The user can enter two numbers and choose which operation to perform. The
operation's outcome will be displayed on the screen.
OUTPUT SCREEN:
After running the upper java code this calculator screen will be displayed.

JUNIT SCRIPTS:
To write JUnit tests for the Calculator application, we will focus on testing the core calculation
logics addition, subtraction, multiplication, division, and negation. We will simulate button clicks
programmatically to verify that the expected results are being produced.

➢ JUnit Tests:
➢ Test cases:

• testAddition: Simulates pressing buttons for 2 + 3 = and checks if the result is 5.0.

• testSubtraction: Simulates 5 - 2 = and verifies the result is 3.0.

• testMultiplication: Simulates 4 * 3 = and checks for 12.0.

• testDivision: Simulates 9 / 3 = and ensures the result is 3.0.

• testNegation: Tests if the negation button works by converting 5 to -5.

• testClear: Verifies if the clear button properly empties the text field.

• testDelete: Checks if the delete button removes the last entered digit correctly.

➢ JUnit Test Results:

You might also like