SlideShare a Scribd company logo
1 of 24
Software Testing Lab
(Lab 7 & 8)
By: Ms. Aroosa Hameed
DEPARTMENT OF SOFTWARE ENGINEERING (DSE)
Foundation University Rawalpindi Campus (FURC)
Lab Agenda
• Unit Testing
• What is NUnit
• NUnit
 Introduction
 Setup
 Configuration
• Example (Test case)
• Exercise
SEN 461L - Software Testing Lab by Aroosa Hameed 2
What is unit testing
• Unit testing is a software testing method by which individual units of source code
are tested to determine whether they are fit for use.
• Units are:
Functions.
Methods.
Class.
SEN 461L - Software Testing Lab by Aroosa Hameed 3
Unit Testing (Cont.)
• Intuitively, one can view a unit as the smallest testable part of an application.
• Unit tests are short code fragments created by programmers during the
development process.
• It forms the basis for component testing.
• When we test individual function behavior without touching any other functions
and determine whether it works exactly as per the requirements or not that is
called Unit Testing.
SEN 461L - Software Testing Lab by Aroosa Hameed 4
Unit Testing (Cont.)
• Some of the advantages of Unit Testing:
 Defects found early in development life cycle
 Reliable Code
 Maintainable code
 Faster testing by only single click of action
SEN 461L - Software Testing Lab by Aroosa Hameed 5
NUnit
• NUnit is a unit testing framework.
• It is the most used framework for writing unit test cases.
• Test Assemblies:
 It is suggested to write testing code in different assemblies called Test
Assemblies. These assemblies only contain testing code nothing else.
 We need to run these test assemblies to check whether all test cases are
passed or failed.
 For that we required Test Runner.
SEN 461L - Software Testing Lab by Aroosa Hameed 6
NUnit
• Test Runners are UI tool which actually run NUnit test cases and show the result
of test cases whether they are passed or failed.
• NUnit is very easy to use. It only provides some custom attributes and some static
Assert classes.
• With the combination of custom attributes and static classes, we can write unit
test cases easily.
SEN 461L - Software Testing Lab by Aroosa Hameed 7
NUnit
• Custom attributes provides hint to NUnit test runners that these classes or
functions contains unit testing code.
• Assert classes is used to test the conditions whether system under test (SUT)
satisfy a condition or not.
• If condition is satisfied then test is pass else fail.
SEN 461L - Software Testing Lab by Aroosa Hameed 8
NUnit
• Some of the custom attributes are:
 TestFixture
 Setup
 TearDown
 Test
 Category
 Ignore
 TestCase
 Repeat
 MaxTime
SEN 461L - Software Testing Lab by Aroosa Hameed 9
NUnit Setup
• There are two steps in configure NUnit project environment:
1. Configure Project with NUnit assemblies
2. Setup TestRunners which show the results of NUnit test cases
SEN 461L - Software Testing Lab by Aroosa Hameed 10
NUnit Setup
• We always creates separate project when creating project for NUnit.
• According to naming conventions test project name should be [Project Under
Test].[Tests].
• For example, if we are testing the project name "CustomerOrderService" then
test project name should be "CustomerOrderService.Tests"
SEN 461L - Software Testing Lab by Aroosa Hameed 11
NUnit Setup (Configuring Nunit Assemblies)
1. Visual Studio -> New Project -> Class Library -> Name: CustomerOrderService
2. Right click on solution -> Add New Project -> Class Library -> Name:
CustomerOrderService.Tests
• In CustomerOrderService project, we write code for business logic
• In second project CustomerOrderService.Tests we write test cases for
CustomerOrderService project.
SEN 461L - Software Testing Lab by Aroosa Hameed 12
NUnit Setup (Configuring Nunit Assemblies)
• Right click on CustomerOrderService.Tests and choose "Manage NuGet
Packages".
• In NuGet search box, Choose Browse tab and type Nunit in search textbox.
• Choose NUnit and click on Install button.
• NUnit assembly (nunit.framework) is added to our test project.
• Add reference of our CustomerOrderService class library to test project.
• Choose add reference in test project -> Project - Solution tab -> Mark the
checkbox before the CustomerOrderService -> Click on OK button.
SEN 461L - Software Testing Lab by Aroosa Hameed 13
NUnit Setup (Configuring Nunit Assemblies)
SEN 461L - Software Testing Lab by Aroosa Hameed 14
NUnit Setup (Configuring TestRunners)
• For setup TestRunners, we need to add Nunit Test Adapter from NuGet packages.
Follow the below steps:
1. Right click on CustomerOrderService.Tests and choose 'Manage NuGet
Packages'
2. Choose NUnit3TestAdapter and click on Install button.
SEN 461L - Software Testing Lab by Aroosa Hameed 15
NUnit Setup (Configuring TestRunners)
SEN 461L - Software Testing Lab by Aroosa Hameed 16
NUnit
Test Case:
A set of statements executed by a tester to determine if the program
under test behaves as expected.
SEN 461L - Software Testing Lab by Aroosa Hameed 17
NUnit
SEN 461L - Software Testing Lab by Aroosa Hameed 18
NUnit
• Test case is composed of three parts
• Test Data
• Test Sequence
• Test Oracle
SEN 461L - Software Testing Lab by Aroosa Hameed 19
NUnit
SEN 461L - Software Testing Lab by Aroosa Hameed 20
• Test data is :
• A set of values, one for each input variable
• Input given to a software program
NUnit
SEN 461L - Software Testing Lab by Aroosa Hameed 21
NUnit
SEN 461L - Software Testing Lab by Aroosa Hameed 22
• Order of execution of test case is Test sequence.
• Test oracle:
The entity that perform task of checking correctness of observed
behavior.
NUnit
SEN 461L - Software Testing Lab by Aroosa Hameed 23
NUnit
SEN 461L - Software Testing Lab by Aroosa Hameed 24
You have to develop a small program that reads three integer values
from console. The three values represent the lengths of the sides of a
triangle
The program first checks if the triangle is valid. Condition for valid
triangle:
• Sum of any two sides should be greater than the third side
Write a set of test cases to properly test the program

More Related Content

What's hot

TEST EXECUTION AND REPORTING
TEST EXECUTION AND REPORTINGTEST EXECUTION AND REPORTING
TEST EXECUTION AND REPORTINGsuhasreddy1
 
Types of Software Testing
Types of Software TestingTypes of Software Testing
Types of Software TestingNishant Worah
 
Software testing
Software testingSoftware testing
Software testingBharath K
 
Software Testing & Debugging
Software Testing & DebuggingSoftware Testing & Debugging
Software Testing & DebuggingComputing Cage
 
Mt s12 test_execution
Mt s12 test_executionMt s12 test_execution
Mt s12 test_executionTestingGeeks
 
Testing (System Analysis and Design)
Testing (System Analysis and Design)Testing (System Analysis and Design)
Testing (System Analysis and Design)Areeb Khan
 
Manual testing-training-institute-in-marathahalli
Manual testing-training-institute-in-marathahalliManual testing-training-institute-in-marathahalli
Manual testing-training-institute-in-marathahallisiyaram ray
 
Testing concepts [3] - Software Testing Techniques (CIS640)
Testing concepts [3] - Software Testing Techniques (CIS640)Testing concepts [3] - Software Testing Techniques (CIS640)
Testing concepts [3] - Software Testing Techniques (CIS640)Venkatesh Prasad Ranganath
 
Basic Guide to Manual Testing
Basic Guide to Manual TestingBasic Guide to Manual Testing
Basic Guide to Manual TestingHiral Gosani
 
Basic software-testing-concepts
Basic software-testing-conceptsBasic software-testing-concepts
Basic software-testing-conceptsmedsherb
 
TEST_AUTOMATION_CASE_STUDY_(2)2[1]
TEST_AUTOMATION_CASE_STUDY_(2)2[1]TEST_AUTOMATION_CASE_STUDY_(2)2[1]
TEST_AUTOMATION_CASE_STUDY_(2)2[1]Clive Dall
 
Software testing and process
Software testing and processSoftware testing and process
Software testing and processgouravkalbalia
 
How To Transform the Manual Testing Process to Incorporate Test Automation
How To Transform the Manual Testing Process to Incorporate Test AutomationHow To Transform the Manual Testing Process to Incorporate Test Automation
How To Transform the Manual Testing Process to Incorporate Test AutomationRanorex
 

What's hot (20)

TEST EXECUTION AND REPORTING
TEST EXECUTION AND REPORTINGTEST EXECUTION AND REPORTING
TEST EXECUTION AND REPORTING
 
Types of Software Testing
Types of Software TestingTypes of Software Testing
Types of Software Testing
 
Software testing
Software testingSoftware testing
Software testing
 
Software Testing & Debugging
Software Testing & DebuggingSoftware Testing & Debugging
Software Testing & Debugging
 
Testing Tools
Testing ToolsTesting Tools
Testing Tools
 
SoftwareTesting
SoftwareTestingSoftwareTesting
SoftwareTesting
 
Automation using ibm rft
Automation using ibm rftAutomation using ibm rft
Automation using ibm rft
 
Mt s12 test_execution
Mt s12 test_executionMt s12 test_execution
Mt s12 test_execution
 
Automation Testing
Automation TestingAutomation Testing
Automation Testing
 
Transactionflow
TransactionflowTransactionflow
Transactionflow
 
Testing (System Analysis and Design)
Testing (System Analysis and Design)Testing (System Analysis and Design)
Testing (System Analysis and Design)
 
Manual testing-training-institute-in-marathahalli
Manual testing-training-institute-in-marathahalliManual testing-training-institute-in-marathahalli
Manual testing-training-institute-in-marathahalli
 
Testing concepts [3] - Software Testing Techniques (CIS640)
Testing concepts [3] - Software Testing Techniques (CIS640)Testing concepts [3] - Software Testing Techniques (CIS640)
Testing concepts [3] - Software Testing Techniques (CIS640)
 
Basic Guide to Manual Testing
Basic Guide to Manual TestingBasic Guide to Manual Testing
Basic Guide to Manual Testing
 
Basic software-testing-concepts
Basic software-testing-conceptsBasic software-testing-concepts
Basic software-testing-concepts
 
Software Testing and Debugging
Software Testing and DebuggingSoftware Testing and Debugging
Software Testing and Debugging
 
TEST_AUTOMATION_CASE_STUDY_(2)2[1]
TEST_AUTOMATION_CASE_STUDY_(2)2[1]TEST_AUTOMATION_CASE_STUDY_(2)2[1]
TEST_AUTOMATION_CASE_STUDY_(2)2[1]
 
Software testing and process
Software testing and processSoftware testing and process
Software testing and process
 
How To Transform the Manual Testing Process to Incorporate Test Automation
How To Transform the Manual Testing Process to Incorporate Test AutomationHow To Transform the Manual Testing Process to Incorporate Test Automation
How To Transform the Manual Testing Process to Incorporate Test Automation
 
Automation Framework/QTP Framework
Automation Framework/QTP FrameworkAutomation Framework/QTP Framework
Automation Framework/QTP Framework
 

Similar to Software testing lab 7 & 8

SE Group H.pptx
SE Group H.pptxSE Group H.pptx
SE Group H.pptxStudyvAbhi
 
Object Oriented Testing(OOT) presentation slides
Object Oriented Testing(OOT) presentation slidesObject Oriented Testing(OOT) presentation slides
Object Oriented Testing(OOT) presentation slidesPunjab University
 
Week 14 Unit Testing.pptx
Week 14  Unit Testing.pptxWeek 14  Unit Testing.pptx
Week 14 Unit Testing.pptxmianshafa
 
Lecture #6. automation testing (andrey oleynik)
Lecture #6. automation testing (andrey oleynik)Lecture #6. automation testing (andrey oleynik)
Lecture #6. automation testing (andrey oleynik)Andrey Oleynik
 
Tools for Software Testing
Tools for Software TestingTools for Software Testing
Tools for Software TestingMohammed Moishin
 
Object oriented testing
Object oriented testingObject oriented testing
Object oriented testingHaris Jamil
 
Beginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBeginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBaskar K
 
Objectorientedtesting 160320132146
Objectorientedtesting 160320132146Objectorientedtesting 160320132146
Objectorientedtesting 160320132146vidhyyav
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkOnkar Deshpande
 
Software Testing Strategy
Software Testing StrategySoftware Testing Strategy
Software Testing StrategyAjeng Savitri
 
Laravel Load Testing: Strategies and Tools
Laravel Load Testing: Strategies and ToolsLaravel Load Testing: Strategies and Tools
Laravel Load Testing: Strategies and ToolsMuhammad Shehata
 
Structured system analysis and design
Structured system analysis and design Structured system analysis and design
Structured system analysis and design Jayant Dalvi
 
An Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitAn Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitweili_at_slideshare
 
DSL, Gfast and Wireless Test Software: Test Sentinel
DSL, Gfast and Wireless Test Software: Test SentinelDSL, Gfast and Wireless Test Software: Test Sentinel
DSL, Gfast and Wireless Test Software: Test SentinelUNH InterOperability Lab
 
Software testing methods, levels and types
Software testing methods, levels and typesSoftware testing methods, levels and types
Software testing methods, levels and typesConfiz
 
Software testing and software development process
Software testing and software development processSoftware testing and software development process
Software testing and software development processGen Aloys Ochola Badde
 
Software engineering Testing technique,test case,test suit design
Software engineering Testing technique,test case,test suit designSoftware engineering Testing technique,test case,test suit design
Software engineering Testing technique,test case,test suit designMaitree Patel
 

Similar to Software testing lab 7 & 8 (20)

SE Group H.pptx
SE Group H.pptxSE Group H.pptx
SE Group H.pptx
 
Object Oriented Testing(OOT) presentation slides
Object Oriented Testing(OOT) presentation slidesObject Oriented Testing(OOT) presentation slides
Object Oriented Testing(OOT) presentation slides
 
Week 14 Unit Testing.pptx
Week 14  Unit Testing.pptxWeek 14  Unit Testing.pptx
Week 14 Unit Testing.pptx
 
Lecture #6. automation testing (andrey oleynik)
Lecture #6. automation testing (andrey oleynik)Lecture #6. automation testing (andrey oleynik)
Lecture #6. automation testing (andrey oleynik)
 
Tools for Software Testing
Tools for Software TestingTools for Software Testing
Tools for Software Testing
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Object oriented testing
Object oriented testingObject oriented testing
Object oriented testing
 
Beginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBeginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NET
 
SDLCTesting
SDLCTestingSDLCTesting
SDLCTesting
 
Different Types Of Testing
Different Types Of TestingDifferent Types Of Testing
Different Types Of Testing
 
Objectorientedtesting 160320132146
Objectorientedtesting 160320132146Objectorientedtesting 160320132146
Objectorientedtesting 160320132146
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
Software Testing Strategy
Software Testing StrategySoftware Testing Strategy
Software Testing Strategy
 
Laravel Load Testing: Strategies and Tools
Laravel Load Testing: Strategies and ToolsLaravel Load Testing: Strategies and Tools
Laravel Load Testing: Strategies and Tools
 
Structured system analysis and design
Structured system analysis and design Structured system analysis and design
Structured system analysis and design
 
An Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitAn Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnit
 
DSL, Gfast and Wireless Test Software: Test Sentinel
DSL, Gfast and Wireless Test Software: Test SentinelDSL, Gfast and Wireless Test Software: Test Sentinel
DSL, Gfast and Wireless Test Software: Test Sentinel
 
Software testing methods, levels and types
Software testing methods, levels and typesSoftware testing methods, levels and types
Software testing methods, levels and types
 
Software testing and software development process
Software testing and software development processSoftware testing and software development process
Software testing and software development process
 
Software engineering Testing technique,test case,test suit design
Software engineering Testing technique,test case,test suit designSoftware engineering Testing technique,test case,test suit design
Software engineering Testing technique,test case,test suit design
 

Recently uploaded

Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 

Recently uploaded (20)

Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 

Software testing lab 7 & 8

  • 1. Software Testing Lab (Lab 7 & 8) By: Ms. Aroosa Hameed DEPARTMENT OF SOFTWARE ENGINEERING (DSE) Foundation University Rawalpindi Campus (FURC)
  • 2. Lab Agenda • Unit Testing • What is NUnit • NUnit  Introduction  Setup  Configuration • Example (Test case) • Exercise SEN 461L - Software Testing Lab by Aroosa Hameed 2
  • 3. What is unit testing • Unit testing is a software testing method by which individual units of source code are tested to determine whether they are fit for use. • Units are: Functions. Methods. Class. SEN 461L - Software Testing Lab by Aroosa Hameed 3
  • 4. Unit Testing (Cont.) • Intuitively, one can view a unit as the smallest testable part of an application. • Unit tests are short code fragments created by programmers during the development process. • It forms the basis for component testing. • When we test individual function behavior without touching any other functions and determine whether it works exactly as per the requirements or not that is called Unit Testing. SEN 461L - Software Testing Lab by Aroosa Hameed 4
  • 5. Unit Testing (Cont.) • Some of the advantages of Unit Testing:  Defects found early in development life cycle  Reliable Code  Maintainable code  Faster testing by only single click of action SEN 461L - Software Testing Lab by Aroosa Hameed 5
  • 6. NUnit • NUnit is a unit testing framework. • It is the most used framework for writing unit test cases. • Test Assemblies:  It is suggested to write testing code in different assemblies called Test Assemblies. These assemblies only contain testing code nothing else.  We need to run these test assemblies to check whether all test cases are passed or failed.  For that we required Test Runner. SEN 461L - Software Testing Lab by Aroosa Hameed 6
  • 7. NUnit • Test Runners are UI tool which actually run NUnit test cases and show the result of test cases whether they are passed or failed. • NUnit is very easy to use. It only provides some custom attributes and some static Assert classes. • With the combination of custom attributes and static classes, we can write unit test cases easily. SEN 461L - Software Testing Lab by Aroosa Hameed 7
  • 8. NUnit • Custom attributes provides hint to NUnit test runners that these classes or functions contains unit testing code. • Assert classes is used to test the conditions whether system under test (SUT) satisfy a condition or not. • If condition is satisfied then test is pass else fail. SEN 461L - Software Testing Lab by Aroosa Hameed 8
  • 9. NUnit • Some of the custom attributes are:  TestFixture  Setup  TearDown  Test  Category  Ignore  TestCase  Repeat  MaxTime SEN 461L - Software Testing Lab by Aroosa Hameed 9
  • 10. NUnit Setup • There are two steps in configure NUnit project environment: 1. Configure Project with NUnit assemblies 2. Setup TestRunners which show the results of NUnit test cases SEN 461L - Software Testing Lab by Aroosa Hameed 10
  • 11. NUnit Setup • We always creates separate project when creating project for NUnit. • According to naming conventions test project name should be [Project Under Test].[Tests]. • For example, if we are testing the project name "CustomerOrderService" then test project name should be "CustomerOrderService.Tests" SEN 461L - Software Testing Lab by Aroosa Hameed 11
  • 12. NUnit Setup (Configuring Nunit Assemblies) 1. Visual Studio -> New Project -> Class Library -> Name: CustomerOrderService 2. Right click on solution -> Add New Project -> Class Library -> Name: CustomerOrderService.Tests • In CustomerOrderService project, we write code for business logic • In second project CustomerOrderService.Tests we write test cases for CustomerOrderService project. SEN 461L - Software Testing Lab by Aroosa Hameed 12
  • 13. NUnit Setup (Configuring Nunit Assemblies) • Right click on CustomerOrderService.Tests and choose "Manage NuGet Packages". • In NuGet search box, Choose Browse tab and type Nunit in search textbox. • Choose NUnit and click on Install button. • NUnit assembly (nunit.framework) is added to our test project. • Add reference of our CustomerOrderService class library to test project. • Choose add reference in test project -> Project - Solution tab -> Mark the checkbox before the CustomerOrderService -> Click on OK button. SEN 461L - Software Testing Lab by Aroosa Hameed 13
  • 14. NUnit Setup (Configuring Nunit Assemblies) SEN 461L - Software Testing Lab by Aroosa Hameed 14
  • 15. NUnit Setup (Configuring TestRunners) • For setup TestRunners, we need to add Nunit Test Adapter from NuGet packages. Follow the below steps: 1. Right click on CustomerOrderService.Tests and choose 'Manage NuGet Packages' 2. Choose NUnit3TestAdapter and click on Install button. SEN 461L - Software Testing Lab by Aroosa Hameed 15
  • 16. NUnit Setup (Configuring TestRunners) SEN 461L - Software Testing Lab by Aroosa Hameed 16
  • 17. NUnit Test Case: A set of statements executed by a tester to determine if the program under test behaves as expected. SEN 461L - Software Testing Lab by Aroosa Hameed 17
  • 18. NUnit SEN 461L - Software Testing Lab by Aroosa Hameed 18
  • 19. NUnit • Test case is composed of three parts • Test Data • Test Sequence • Test Oracle SEN 461L - Software Testing Lab by Aroosa Hameed 19
  • 20. NUnit SEN 461L - Software Testing Lab by Aroosa Hameed 20 • Test data is : • A set of values, one for each input variable • Input given to a software program
  • 21. NUnit SEN 461L - Software Testing Lab by Aroosa Hameed 21
  • 22. NUnit SEN 461L - Software Testing Lab by Aroosa Hameed 22 • Order of execution of test case is Test sequence. • Test oracle: The entity that perform task of checking correctness of observed behavior.
  • 23. NUnit SEN 461L - Software Testing Lab by Aroosa Hameed 23
  • 24. NUnit SEN 461L - Software Testing Lab by Aroosa Hameed 24 You have to develop a small program that reads three integer values from console. The three values represent the lengths of the sides of a triangle The program first checks if the triangle is valid. Condition for valid triangle: • Sum of any two sides should be greater than the third side Write a set of test cases to properly test the program