SlideShare a Scribd company logo
SOFTWARE TESTING
Get the bugs out!
1
Why Test Software?
2
 Software testing enables making objective assessments
regarding the degree of conformance of the system to stated
requirements and specifications. Testing verifies that the
system meets the different requirements including, functional,
performance, reliability, security, usability and so on.
Objective Assessment: So What?
3
 Consider the role of product owner (individual or company)
 What is their responsibility regarding software?
 When to release it?
 What level or risks are tolerable?
 To answer these questions what do they need to know?
 How many bugs exist?
 What’s the likelihood of a bug happening to users
 What could that bug do to users?
 Cost of removing bugs vs cost of lost revenue vs brand
damage costs
More than finding bugs
4
 It is important for software testing to verify and validate that
the product meets the stated requirements / specifications.

What is the value of good software?
5
 Good will with customers  more revenue
 Word of mouth  sell more
 Trust  buy more
 Reduces support costs
 Allows development team to work on adding more value (new
features and feature improvements
 Greater employee morale
Types of Software Development Tests
7
 Unit testing
 Integration testing
 Functional testing
Unit testing
8
 Unit tests are used to test individual code components and
ensure that code works the way it was intended to.
 Unit tests are written and executed by developers.
 Most of the time a testing framework like JUnit or TestNG is
used.
 Test cases are typically written at a method level and executed
via automation.
Integration Testing
9
 Integration tests check if the system as a whole works.
 Integration testing is also done by developers, but rather than
testing individual components, it aims to
test across components.
 A system consists of many separate components like code,
database, web servers, etc. (more than JUST CODE)
 Integration tests are able to spot issues like wiring of
components, network access, database issues, etc.
Functional Testing
10
 Functional tests check that each feature is implemented
correctly by comparing the results for a given input against the
specification.
 Typically, this is not done at a developer level.
 Functional tests are executed by a separate testing team.
 Test cases are written based on the specification and the actual
results are compared with the expected results.
 Several tools are available for automated functional testing
like Selenium and QTP.
UNIT TESTING
11
Today's Goal
 Functions/methods are the basic building block of programs.
 Today, you'll learn to test functions, and how to design testable
functions.
12
What is a unit test?
13
 A unit test is a piece of code that invokes a unit of work and
checks one specific end result of that unit of work. If the
assumptions on the end result turn out to be wrong, the unit
test has failed. A unit test’s scope can span as little as a
method or as much as multiple classes.
Testing Functions
 Amy is writing a program. She adds functionality by defining a
new function, and adding a function call to the new function in
the main program somewhere. Now she needs to test the new
code.
 Two basic approaches to testing the new code:
1. Run the entire program
 The function is tested when it is invoked during the program
execution
2. Test the function by itself, somehow
Which do you think will be more efficient?
14
Manual Unit Test
 A unit test is a program that tests
a function to determine if it works
properly
 A manual unit test
 Gets test input from the user
 Invokes the function on the test
input
 Displays the result of the function
 How would you use a unit test to
determine that roundIt() works
correctly?
 How does the test - debug cycle
go?
def roundIt(num: float) -> int:
return int(num + .5)
# ---- manual unit test ----
x = float(input('Enter a number:'))
result = roundIt(x)
print('Result: ', result)
15
Automated Unit Test
 An automated unit test
 Invokes the function on
predetermined test input
 Checks that the function
produced the expected result
 Displays a pass / fail
message
 Advantages?
 Disadvantages?
def roundIt(num: float) -> int:
return int(num + .5)
# ---- automated unit test ----
result = roundIt(9.7)
if result == 10:
print("Test 1: PASS")
else:
print("Test 1: FAIL")
result = roundIt(8.2)
if result == 8:
print("Test 2: PASS")
else:
print("Test 2: FAIL")
16
Automated Unit Test with assert
 The assert statement
 Performs a comparison
 If the comparison is True,
does nothing
 If the comparison is False,
displays an error and stops
the program
 assert statements help us
write concise, automated
unit tests
 Demo: Run the test
def roundIt(num: float) -> int:
return int(num + .5)
# ---- automated unit test ----
result = roundIt(9.7)
assert result == 10
result = roundIt(8.2)
assert result == 8
print("All tests passed!")
17
A Shorter Test
 This is Nice.
 Two issues:
 To test the function, we have
to copy it between the "real
program" and this unit test
 Assertion failure messages
could be more helpful
To solve these, we'll use pytest,
a unit test framework
def roundIt(num: float) -> int:
return int(num + .5)
# ---- automated unit test ----
assert roundIt(9.7) == 10
assert roundIt(8.2) == 8
print("All tests passed!")
18
A pytest Unit Test
 To create a pytest Unit Test:
 Define a unit test function named
test_something
 Place one or more assertions
inside
 These tests can be located in the
same file as the "real program," as
long as you put the real program
inside a special if statement, as
shown
 To run a pytest Unit Test from
command prompt:
 pytest program.py
 Note: pytest must first be
installed...
def roundIt(num: float) -> int:
return int(num + .5)
def test_roundIt():
assert roundIt(9.7) == 10
assert roundIt(8.2) == 8
if __name__ == "__main__":
# --- "real program" here ---
19
What's with this if statement?
if __name__ == "__main__":
# --- "real program" here ---
 This if condition above is true when the
program is executed using the python
command:
 python myprog.py
 The if condition is false when the program is
executed using pytest
 pytest myprog.py
We don't want pytest to execute the main
program...
20
pytest Unit Tests
 A pytest Unit Test can have
more than one test method
 It's good practice to have a
separate test method for
each type of test
 That way, when a test fails,
you can debug the issue
more easily
def roundIt(num: float) -> int:
return int(num + .5)
# ---- automated unit test ----
def test_roundIt_rounds_up():
assert roundIt(9.7) == 10
def test_roundIt_rounds_down():
assert roundIt(8.2) == 8
21
Designing Testable Functions
 Some functions can't be
tested with an automated
unit test.
 A testable function
 Gets input from parameters
 Returns a result
 Does no input / output
# This function is not testable
def roundIt(num: float) -> int:
print(int(num + .5))
22
Python unit test tutorial
35
Ad

More Related Content

What's hot (20)

SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
Amr E. Mohamed
 
Advanced Software Test Automation
Advanced Software Test AutomationAdvanced Software Test Automation
Advanced Software Test Automation
Unmesh Ballal
 
Selenium Demo
Selenium DemoSelenium Demo
Selenium Demo
Sreenivasula Reddy Nallagari
 
How to Design a Successful Test Automation Strategy
How to Design a Successful Test Automation Strategy How to Design a Successful Test Automation Strategy
How to Design a Successful Test Automation Strategy
Impetus Technologies
 
Automation Framework/QTP Framework
Automation Framework/QTP FrameworkAutomation Framework/QTP Framework
Automation Framework/QTP Framework
HeyDay Software Solutions
 
Sdlc
SdlcSdlc
Sdlc
Mahfuz1061
 
Acceptance test driven development
Acceptance test driven developmentAcceptance test driven development
Acceptance test driven development
Editor Jacotech
 
Software Engineering- Types of Testing
Software Engineering- Types of TestingSoftware Engineering- Types of Testing
Software Engineering- Types of Testing
Trinity Dwarka
 
Management Issues in Test Automation
Management Issues in Test AutomationManagement Issues in Test Automation
Management Issues in Test Automation
TechWell
 
Growing Object Oriented Software
Growing Object Oriented SoftwareGrowing Object Oriented Software
Growing Object Oriented Software
Annmarie Lanesey
 
It Seemed a Good Idea at the Time: Intelligent Mistakes in Test Automation
It Seemed a Good Idea at the Time: Intelligent Mistakes in Test AutomationIt Seemed a Good Idea at the Time: Intelligent Mistakes in Test Automation
It Seemed a Good Idea at the Time: Intelligent Mistakes in Test Automation
TechWell
 
Agile Acceptance testing with Fitnesse
Agile Acceptance testing with FitnesseAgile Acceptance testing with Fitnesse
Agile Acceptance testing with Fitnesse
ClareMcLennan
 
Software Engineering-Part 1
Software Engineering-Part 1Software Engineering-Part 1
Software Engineering-Part 1
Shrija Madhu
 
Practical Software Testing Tools
Practical Software Testing ToolsPractical Software Testing Tools
Practical Software Testing Tools
Dr Ganesh Iyer
 
manual-testing
manual-testingmanual-testing
manual-testing
Kanak Mane
 
Sqa unit1
Sqa unit1Sqa unit1
Sqa unit1
kannaki
 
Software testing basic concepts
Software testing basic conceptsSoftware testing basic concepts
Software testing basic concepts
Hưng Hoàng
 
Synthesizing Continuous Deployment Practices in Software Development
Synthesizing Continuous Deployment Practices in Software DevelopmentSynthesizing Continuous Deployment Practices in Software Development
Synthesizing Continuous Deployment Practices in Software Development
Akond Rahman
 
Software testing tools (free and open source)
Software testing tools (free and open source)Software testing tools (free and open source)
Software testing tools (free and open source)
Wael Mansour
 
Chapter 14
Chapter 14Chapter 14
Chapter 14
Benjamin Yu
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
Amr E. Mohamed
 
Advanced Software Test Automation
Advanced Software Test AutomationAdvanced Software Test Automation
Advanced Software Test Automation
Unmesh Ballal
 
How to Design a Successful Test Automation Strategy
How to Design a Successful Test Automation Strategy How to Design a Successful Test Automation Strategy
How to Design a Successful Test Automation Strategy
Impetus Technologies
 
Acceptance test driven development
Acceptance test driven developmentAcceptance test driven development
Acceptance test driven development
Editor Jacotech
 
Software Engineering- Types of Testing
Software Engineering- Types of TestingSoftware Engineering- Types of Testing
Software Engineering- Types of Testing
Trinity Dwarka
 
Management Issues in Test Automation
Management Issues in Test AutomationManagement Issues in Test Automation
Management Issues in Test Automation
TechWell
 
Growing Object Oriented Software
Growing Object Oriented SoftwareGrowing Object Oriented Software
Growing Object Oriented Software
Annmarie Lanesey
 
It Seemed a Good Idea at the Time: Intelligent Mistakes in Test Automation
It Seemed a Good Idea at the Time: Intelligent Mistakes in Test AutomationIt Seemed a Good Idea at the Time: Intelligent Mistakes in Test Automation
It Seemed a Good Idea at the Time: Intelligent Mistakes in Test Automation
TechWell
 
Agile Acceptance testing with Fitnesse
Agile Acceptance testing with FitnesseAgile Acceptance testing with Fitnesse
Agile Acceptance testing with Fitnesse
ClareMcLennan
 
Software Engineering-Part 1
Software Engineering-Part 1Software Engineering-Part 1
Software Engineering-Part 1
Shrija Madhu
 
Practical Software Testing Tools
Practical Software Testing ToolsPractical Software Testing Tools
Practical Software Testing Tools
Dr Ganesh Iyer
 
manual-testing
manual-testingmanual-testing
manual-testing
Kanak Mane
 
Sqa unit1
Sqa unit1Sqa unit1
Sqa unit1
kannaki
 
Software testing basic concepts
Software testing basic conceptsSoftware testing basic concepts
Software testing basic concepts
Hưng Hoàng
 
Synthesizing Continuous Deployment Practices in Software Development
Synthesizing Continuous Deployment Practices in Software DevelopmentSynthesizing Continuous Deployment Practices in Software Development
Synthesizing Continuous Deployment Practices in Software Development
Akond Rahman
 
Software testing tools (free and open source)
Software testing tools (free and open source)Software testing tools (free and open source)
Software testing tools (free and open source)
Wael Mansour
 

Similar to Upstate CSCI 540 Unit testing (20)

SE2011_10.ppt
SE2011_10.pptSE2011_10.ppt
SE2011_10.ppt
MuhammedAlTijaniMrja
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
RubenGray1
 
Ian Sommerville, Software Engineering, 9th EditionCh 8
Ian Sommerville,  Software Engineering, 9th EditionCh 8Ian Sommerville,  Software Engineering, 9th EditionCh 8
Ian Sommerville, Software Engineering, 9th EditionCh 8
Mohammed Romi
 
Software enginnenring Book Slides By summer
Software enginnenring Book Slides By summerSoftware enginnenring Book Slides By summer
Software enginnenring Book Slides By summer
p229279
 
Unit testing for WordPress
Unit testing for WordPressUnit testing for WordPress
Unit testing for WordPress
Harshad Mane
 
1.1 Chapter_22_ Unit Testing-testing (1).pptx
1.1 Chapter_22_ Unit Testing-testing (1).pptx1.1 Chapter_22_ Unit Testing-testing (1).pptx
1.1 Chapter_22_ Unit Testing-testing (1).pptx
tiyaAbid
 
Ch8
Ch8Ch8
Ch8
Mohammed Romi
 
Ch8
Ch8Ch8
Ch8
Keith Jasper Mier
 
Lecture 11 Software Engineering Testing Slide
Lecture 11 Software Engineering Testing SlideLecture 11 Software Engineering Testing Slide
Lecture 11 Software Engineering Testing Slide
zola59
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
priya_trivedi
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
priya_trivedi
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
Priya Sharma
 
Software testing
Software testingSoftware testing
Software testing
balamurugan.k Kalibalamurugan
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2
Tricode (part of Dept)
 
PHPUnit
PHPUnitPHPUnit
PHPUnit
Hampton Roads PHP User Grop
 
Testing Software Solutions
Testing Software SolutionsTesting Software Solutions
Testing Software Solutions
gavhays
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
Dror Helper
 
Software testing
Software testingSoftware testing
Software testing
Aman Adhikari
 
Testing methodology
Testing methodologyTesting methodology
Testing methodology
Dina Hanbazazah
 
Software testing
Software testingSoftware testing
Software testing
Eng Ibrahem
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
RubenGray1
 
Ian Sommerville, Software Engineering, 9th EditionCh 8
Ian Sommerville,  Software Engineering, 9th EditionCh 8Ian Sommerville,  Software Engineering, 9th EditionCh 8
Ian Sommerville, Software Engineering, 9th EditionCh 8
Mohammed Romi
 
Software enginnenring Book Slides By summer
Software enginnenring Book Slides By summerSoftware enginnenring Book Slides By summer
Software enginnenring Book Slides By summer
p229279
 
Unit testing for WordPress
Unit testing for WordPressUnit testing for WordPress
Unit testing for WordPress
Harshad Mane
 
1.1 Chapter_22_ Unit Testing-testing (1).pptx
1.1 Chapter_22_ Unit Testing-testing (1).pptx1.1 Chapter_22_ Unit Testing-testing (1).pptx
1.1 Chapter_22_ Unit Testing-testing (1).pptx
tiyaAbid
 
Lecture 11 Software Engineering Testing Slide
Lecture 11 Software Engineering Testing SlideLecture 11 Software Engineering Testing Slide
Lecture 11 Software Engineering Testing Slide
zola59
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2
Tricode (part of Dept)
 
Testing Software Solutions
Testing Software SolutionsTesting Software Solutions
Testing Software Solutions
gavhays
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
Dror Helper
 
Software testing
Software testingSoftware testing
Software testing
Eng Ibrahem
 
Ad

More from DanWooster1 (20)

Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9
DanWooster1
 
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
DanWooster1
 
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
DanWooster1
 
Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3
DanWooster1
 
Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2
DanWooster1
 
Upstate CSCI 450 WebDev Chapter 1
Upstate CSCI 450 WebDev Chapter 1Upstate CSCI 450 WebDev Chapter 1
Upstate CSCI 450 WebDev Chapter 1
DanWooster1
 
Upstate CSCI 525 Data Mining Chapter 3
Upstate CSCI 525 Data Mining Chapter 3Upstate CSCI 525 Data Mining Chapter 3
Upstate CSCI 525 Data Mining Chapter 3
DanWooster1
 
Upstate CSCI 525 Data Mining Chapter 2
Upstate CSCI 525 Data Mining Chapter 2Upstate CSCI 525 Data Mining Chapter 2
Upstate CSCI 525 Data Mining Chapter 2
DanWooster1
 
Upstate CSCI 525 Data Mining Chapter 1
Upstate CSCI 525 Data Mining Chapter 1Upstate CSCI 525 Data Mining Chapter 1
Upstate CSCI 525 Data Mining Chapter 1
DanWooster1
 
Upstate CSCI 200 Java Chapter 8 - Arrays
Upstate CSCI 200 Java Chapter 8 - ArraysUpstate CSCI 200 Java Chapter 8 - Arrays
Upstate CSCI 200 Java Chapter 8 - Arrays
DanWooster1
 
Upstate CSCI 200 Java Chapter 7 - OOP
Upstate CSCI 200 Java Chapter 7 - OOPUpstate CSCI 200 Java Chapter 7 - OOP
Upstate CSCI 200 Java Chapter 7 - OOP
DanWooster1
 
CSCI 200 Java Chapter 03 Using Classes
CSCI 200 Java Chapter 03 Using ClassesCSCI 200 Java Chapter 03 Using Classes
CSCI 200 Java Chapter 03 Using Classes
DanWooster1
 
CSCI 200 Java Chapter 02 Data & Expressions
CSCI 200 Java Chapter 02 Data & ExpressionsCSCI 200 Java Chapter 02 Data & Expressions
CSCI 200 Java Chapter 02 Data & Expressions
DanWooster1
 
CSCI 200 Java Chapter 01
CSCI 200 Java Chapter 01CSCI 200 Java Chapter 01
CSCI 200 Java Chapter 01
DanWooster1
 
CSCI 238 Chapter 08 Arrays Textbook Slides
CSCI 238 Chapter 08 Arrays Textbook SlidesCSCI 238 Chapter 08 Arrays Textbook Slides
CSCI 238 Chapter 08 Arrays Textbook Slides
DanWooster1
 
Chapter 6 - More conditionals and loops
Chapter 6 - More conditionals and loopsChapter 6 - More conditionals and loops
Chapter 6 - More conditionals and loops
DanWooster1
 
Upstate CSCI 450 jQuery
Upstate CSCI 450 jQueryUpstate CSCI 450 jQuery
Upstate CSCI 450 jQuery
DanWooster1
 
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13
DanWooster1
 
Upstate CSCI 450 PHP
Upstate CSCI 450 PHPUpstate CSCI 450 PHP
Upstate CSCI 450 PHP
DanWooster1
 
CSCI 238 Chapter 07 - Classes
CSCI 238 Chapter 07 - ClassesCSCI 238 Chapter 07 - Classes
CSCI 238 Chapter 07 - Classes
DanWooster1
 
Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9
DanWooster1
 
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
DanWooster1
 
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
DanWooster1
 
Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3
DanWooster1
 
Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2
DanWooster1
 
Upstate CSCI 450 WebDev Chapter 1
Upstate CSCI 450 WebDev Chapter 1Upstate CSCI 450 WebDev Chapter 1
Upstate CSCI 450 WebDev Chapter 1
DanWooster1
 
Upstate CSCI 525 Data Mining Chapter 3
Upstate CSCI 525 Data Mining Chapter 3Upstate CSCI 525 Data Mining Chapter 3
Upstate CSCI 525 Data Mining Chapter 3
DanWooster1
 
Upstate CSCI 525 Data Mining Chapter 2
Upstate CSCI 525 Data Mining Chapter 2Upstate CSCI 525 Data Mining Chapter 2
Upstate CSCI 525 Data Mining Chapter 2
DanWooster1
 
Upstate CSCI 525 Data Mining Chapter 1
Upstate CSCI 525 Data Mining Chapter 1Upstate CSCI 525 Data Mining Chapter 1
Upstate CSCI 525 Data Mining Chapter 1
DanWooster1
 
Upstate CSCI 200 Java Chapter 8 - Arrays
Upstate CSCI 200 Java Chapter 8 - ArraysUpstate CSCI 200 Java Chapter 8 - Arrays
Upstate CSCI 200 Java Chapter 8 - Arrays
DanWooster1
 
Upstate CSCI 200 Java Chapter 7 - OOP
Upstate CSCI 200 Java Chapter 7 - OOPUpstate CSCI 200 Java Chapter 7 - OOP
Upstate CSCI 200 Java Chapter 7 - OOP
DanWooster1
 
CSCI 200 Java Chapter 03 Using Classes
CSCI 200 Java Chapter 03 Using ClassesCSCI 200 Java Chapter 03 Using Classes
CSCI 200 Java Chapter 03 Using Classes
DanWooster1
 
CSCI 200 Java Chapter 02 Data & Expressions
CSCI 200 Java Chapter 02 Data & ExpressionsCSCI 200 Java Chapter 02 Data & Expressions
CSCI 200 Java Chapter 02 Data & Expressions
DanWooster1
 
CSCI 200 Java Chapter 01
CSCI 200 Java Chapter 01CSCI 200 Java Chapter 01
CSCI 200 Java Chapter 01
DanWooster1
 
CSCI 238 Chapter 08 Arrays Textbook Slides
CSCI 238 Chapter 08 Arrays Textbook SlidesCSCI 238 Chapter 08 Arrays Textbook Slides
CSCI 238 Chapter 08 Arrays Textbook Slides
DanWooster1
 
Chapter 6 - More conditionals and loops
Chapter 6 - More conditionals and loopsChapter 6 - More conditionals and loops
Chapter 6 - More conditionals and loops
DanWooster1
 
Upstate CSCI 450 jQuery
Upstate CSCI 450 jQueryUpstate CSCI 450 jQuery
Upstate CSCI 450 jQuery
DanWooster1
 
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13
DanWooster1
 
Upstate CSCI 450 PHP
Upstate CSCI 450 PHPUpstate CSCI 450 PHP
Upstate CSCI 450 PHP
DanWooster1
 
CSCI 238 Chapter 07 - Classes
CSCI 238 Chapter 07 - ClassesCSCI 238 Chapter 07 - Classes
CSCI 238 Chapter 07 - Classes
DanWooster1
 
Ad

Recently uploaded (20)

TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 

Upstate CSCI 540 Unit testing

  • 2. Why Test Software? 2  Software testing enables making objective assessments regarding the degree of conformance of the system to stated requirements and specifications. Testing verifies that the system meets the different requirements including, functional, performance, reliability, security, usability and so on.
  • 3. Objective Assessment: So What? 3  Consider the role of product owner (individual or company)  What is their responsibility regarding software?  When to release it?  What level or risks are tolerable?  To answer these questions what do they need to know?  How many bugs exist?  What’s the likelihood of a bug happening to users  What could that bug do to users?  Cost of removing bugs vs cost of lost revenue vs brand damage costs
  • 4. More than finding bugs 4  It is important for software testing to verify and validate that the product meets the stated requirements / specifications. 
  • 5. What is the value of good software? 5  Good will with customers  more revenue  Word of mouth  sell more  Trust  buy more  Reduces support costs  Allows development team to work on adding more value (new features and feature improvements  Greater employee morale
  • 6. Types of Software Development Tests 7  Unit testing  Integration testing  Functional testing
  • 7. Unit testing 8  Unit tests are used to test individual code components and ensure that code works the way it was intended to.  Unit tests are written and executed by developers.  Most of the time a testing framework like JUnit or TestNG is used.  Test cases are typically written at a method level and executed via automation.
  • 8. Integration Testing 9  Integration tests check if the system as a whole works.  Integration testing is also done by developers, but rather than testing individual components, it aims to test across components.  A system consists of many separate components like code, database, web servers, etc. (more than JUST CODE)  Integration tests are able to spot issues like wiring of components, network access, database issues, etc.
  • 9. Functional Testing 10  Functional tests check that each feature is implemented correctly by comparing the results for a given input against the specification.  Typically, this is not done at a developer level.  Functional tests are executed by a separate testing team.  Test cases are written based on the specification and the actual results are compared with the expected results.  Several tools are available for automated functional testing like Selenium and QTP.
  • 11. Today's Goal  Functions/methods are the basic building block of programs.  Today, you'll learn to test functions, and how to design testable functions. 12
  • 12. What is a unit test? 13  A unit test is a piece of code that invokes a unit of work and checks one specific end result of that unit of work. If the assumptions on the end result turn out to be wrong, the unit test has failed. A unit test’s scope can span as little as a method or as much as multiple classes.
  • 13. Testing Functions  Amy is writing a program. She adds functionality by defining a new function, and adding a function call to the new function in the main program somewhere. Now she needs to test the new code.  Two basic approaches to testing the new code: 1. Run the entire program  The function is tested when it is invoked during the program execution 2. Test the function by itself, somehow Which do you think will be more efficient? 14
  • 14. Manual Unit Test  A unit test is a program that tests a function to determine if it works properly  A manual unit test  Gets test input from the user  Invokes the function on the test input  Displays the result of the function  How would you use a unit test to determine that roundIt() works correctly?  How does the test - debug cycle go? def roundIt(num: float) -> int: return int(num + .5) # ---- manual unit test ---- x = float(input('Enter a number:')) result = roundIt(x) print('Result: ', result) 15
  • 15. Automated Unit Test  An automated unit test  Invokes the function on predetermined test input  Checks that the function produced the expected result  Displays a pass / fail message  Advantages?  Disadvantages? def roundIt(num: float) -> int: return int(num + .5) # ---- automated unit test ---- result = roundIt(9.7) if result == 10: print("Test 1: PASS") else: print("Test 1: FAIL") result = roundIt(8.2) if result == 8: print("Test 2: PASS") else: print("Test 2: FAIL") 16
  • 16. Automated Unit Test with assert  The assert statement  Performs a comparison  If the comparison is True, does nothing  If the comparison is False, displays an error and stops the program  assert statements help us write concise, automated unit tests  Demo: Run the test def roundIt(num: float) -> int: return int(num + .5) # ---- automated unit test ---- result = roundIt(9.7) assert result == 10 result = roundIt(8.2) assert result == 8 print("All tests passed!") 17
  • 17. A Shorter Test  This is Nice.  Two issues:  To test the function, we have to copy it between the "real program" and this unit test  Assertion failure messages could be more helpful To solve these, we'll use pytest, a unit test framework def roundIt(num: float) -> int: return int(num + .5) # ---- automated unit test ---- assert roundIt(9.7) == 10 assert roundIt(8.2) == 8 print("All tests passed!") 18
  • 18. A pytest Unit Test  To create a pytest Unit Test:  Define a unit test function named test_something  Place one or more assertions inside  These tests can be located in the same file as the "real program," as long as you put the real program inside a special if statement, as shown  To run a pytest Unit Test from command prompt:  pytest program.py  Note: pytest must first be installed... def roundIt(num: float) -> int: return int(num + .5) def test_roundIt(): assert roundIt(9.7) == 10 assert roundIt(8.2) == 8 if __name__ == "__main__": # --- "real program" here --- 19
  • 19. What's with this if statement? if __name__ == "__main__": # --- "real program" here ---  This if condition above is true when the program is executed using the python command:  python myprog.py  The if condition is false when the program is executed using pytest  pytest myprog.py We don't want pytest to execute the main program... 20
  • 20. pytest Unit Tests  A pytest Unit Test can have more than one test method  It's good practice to have a separate test method for each type of test  That way, when a test fails, you can debug the issue more easily def roundIt(num: float) -> int: return int(num + .5) # ---- automated unit test ---- def test_roundIt_rounds_up(): assert roundIt(9.7) == 10 def test_roundIt_rounds_down(): assert roundIt(8.2) == 8 21
  • 21. Designing Testable Functions  Some functions can't be tested with an automated unit test.  A testable function  Gets input from parameters  Returns a result  Does no input / output # This function is not testable def roundIt(num: float) -> int: print(int(num + .5)) 22
  • 22. Python unit test tutorial 35