SlideShare a Scribd company logo
Unit Testing using NunitIntroduction to Art of TestingPresenter:GauravAroraEmail: admin@hyderabadtechies.infoNote: This presentation is presented with courtesy of HyderabadTechies.info
TopicsWhat is unit testing?Step-by-step OverviewWhat is Nunit?Hands-on using Nunit
What is unit testing?Unit Testing is a way/method by which individual units of source code/application are tested to determine if they are fit for use.In other words, we can say method by which individual test one thing at a time [i.e. units] without touching external sources [DB, external files, libraries etc.]
Who is responsible for testing?Primarily job for Unit Testing is completely for Developers. But, when we talk about Quality or testing then it would be a different answer.Everyone who is a developer
Everyone who is a team member
Even it’s the responsibility of customerMain benefits of unit testingMain goal of unit testing to make sure that each and every tested part [i.e. unit] is correct. In Test-Drive-application -Helpful in writing Smaller, tighter, decoupled code
Helpful in Documentation of requirementsWhat do you need?Testing frameworkNUnit, MSTest, MbUnitTest runnerNUnit, MSTest, ReSharperMocking frameworkRhino Mocks, Moq, TypeMockWhy to choose NUnit?A generally asked question, there is a lengthy discussion and story for this, due to shortage of time, we can’t go with topic.Here are some links, go and grab the answer of this question :http://osherove.com/blog/2010/3/5/nunit-vs-mstest-nunit-wins-for-unit-testing.htmlhttp://stackoverflow.com/questions/3678783/mbunit-vs-nunithttp://stackoverflow.com/questions/261139/nunit-vs-mbunit-vs-mstest-vs-xunit-net
What is Nunit?Nunit is unit-testing framework and supports all .Net languages. It has been written entirely in C# [csharp].Refer - http://www.nunit.org/
Start with NunitBefore start, we need nUnit framework:Download from :http://www.nunit.org/index.php?p=downloadhttp://sourceforge.net/projects/nunit/[after download, install per your choice, not going in details of this chapter here…]For more info :http://www.nunit.org/
Pictorial Flow of NunitnUnitDll, exe file XML file (Optional)Processing details on the GUI or Command promptImage : showing [Input & Output]
Nunit : two operational flavorsNunit is having two operational modes:GUI modeGraphical user interface, nothing to type just click button and check the results.CUI [i.e. console] modeConsole mode, runs from command prompt, you need to write commands and check the results.
Nunit : Hands-onBefore this make sure, nunit framework has been downloaded has properly installed at your system.Preferable, download Nunit-2.5.10.msi
Add references to your project
Write Test methods
Run your tests either with GUI or CUI modeNunit : Hands-on… continue…In our Test project we are going to write simple test, which will test our methods for BMI application [a simple Body Mass Index calculator].Coming slides will tell step-by-step creation of project …
Nunit : Hands-on… BMI TestStart your IDE to develop .Net application. In this session we are using VS2010
Select a Class Library project [why choose class library, we are creating a separate project for our tests]
Add reference of nunit.framework.dll in your project
Include ‘NUnit.Framework’ namespace in your projectHands-on: BMI Test
Hands-on: BMI Test-StructureUsingTestFixture AttributeTest ClassSetup attributeTearDown attributeTest attribute
Hands-on : Points of interestIn previous slide we notified :Test class is named with *Tests
Method names are long, defining scenarios
Attribute TestFixture tells the fixture of test class
Method with Setup attribute calls at very first and TearDown calls after every TestMethod, no matters if there will be an exceptionHands-on : ‘AAA’ methodNunit ‘AAA’ method is nothing butArrange :arrange objects, creating and setting them up as necessaryAct :Act on an objectAssertThat something is expected
Lets take a look on Code!
Nunit : CUIConsole mode is one of the modes available of Nunit, lets discuss how to run from command [console window]:The command to execute the exe in console mode is 	nunit-console.exe [filename] [option]
Nunit : CUI - Output
Nunit : CUI - Options*Options/Fixture=STR                    Fixture to test/config=STR                      project configuration to load/XML=STR                         Name of XML output file/transform=STR                name of transform file/xmlConsoledisplay XML to the console/output=STR                     File to receive test output (short :/out=STR) /err=STR                           File to receive test error output/labels                              Label each test in stdout/include = STR                  list of categories to include/exclude = STR                 list of categories to exclude/noshadow                        disable shadow option/thread                             runs thread on a separate thread/wait                                 waitfor input before closing console window   /nologoDo not display the logo/help                                Display help (short format: /?)

More Related Content

PPT
N Unit Presentation
PPTX
Unit testing with NUnit
PDF
An Introduction to Unit Test Using NUnit
PPTX
Hybrid automation framework
PPT
Selenium Automation Framework
PPT
Test Automation Framework Designs
KEY
Selenium Grid
N Unit Presentation
Unit testing with NUnit
An Introduction to Unit Test Using NUnit
Hybrid automation framework
Selenium Automation Framework
Test Automation Framework Designs
Selenium Grid

What's hot (20)

PPT
Test automation using selenium
PPTX
Selenium introduction
PPT
Selenium
PDF
Selenium - Introduction
PPTX
An overview of selenium webdriver
PPTX
Automation - web testing with selenium
PDF
Test Automation Framework Design | www.idexcel.com
PPTX
Setting up Page Object Model in Automation Framework
PDF
Introduction to Selenium grid
PPTX
Test automation
PPTX
Introduction to Agile Testing
PDF
Selenium Page Object Model Using Page Factory | Selenium Tutorial For Beginne...
PDF
Page Object Model and Implementation in Selenium
PPT
Hybrid Automation Framework Development introduction
PDF
Test Automation
PPT
Test automation principles, terminologies and implementations
PDF
Introduction To Mobile-Automation
PPT
Agile QA and Testing process
PPT
PDF
Page object pattern
Test automation using selenium
Selenium introduction
Selenium
Selenium - Introduction
An overview of selenium webdriver
Automation - web testing with selenium
Test Automation Framework Design | www.idexcel.com
Setting up Page Object Model in Automation Framework
Introduction to Selenium grid
Test automation
Introduction to Agile Testing
Selenium Page Object Model Using Page Factory | Selenium Tutorial For Beginne...
Page Object Model and Implementation in Selenium
Hybrid Automation Framework Development introduction
Test Automation
Test automation principles, terminologies and implementations
Introduction To Mobile-Automation
Agile QA and Testing process
Page object pattern
Ad

Viewers also liked (17)

PPT
Huu Le - Tma Open Source For Project Tools
DOCX
Adp junit
PDF
He thong cong cu kiem thu tu dong va dam bao chat luong phan mem
DOC
Bai tap testing junit…..
PPTX
Introduction to testing with MSTest, Visual Studio, and Team Foundation Serve...
ODP
Android Nâng cao-Bài 8-JSON & XML Parsing
PPTX
Kiểm thử bảo mật web
PPTX
NUnit Features Presentation
PPTX
[Seminar] Hướng dẫn viết test case
ODP
Android Nâng cao-Bài 9-Debug in Android Application Development
ODP
Android Nâng cao-Bài 6-Multi theme-adb tool-jUnit
PPTX
Slide đồ án kiểm thử PM
PDF
Giáo trình Tester Full
DOCX
Đồ án kiểm thử phần mềm
PPTX
DOCX
Nunit framework for .NET application
DOC
Bao cao tttn an ninh web
Huu Le - Tma Open Source For Project Tools
Adp junit
He thong cong cu kiem thu tu dong va dam bao chat luong phan mem
Bai tap testing junit…..
Introduction to testing with MSTest, Visual Studio, and Team Foundation Serve...
Android Nâng cao-Bài 8-JSON & XML Parsing
Kiểm thử bảo mật web
NUnit Features Presentation
[Seminar] Hướng dẫn viết test case
Android Nâng cao-Bài 9-Debug in Android Application Development
Android Nâng cao-Bài 6-Multi theme-adb tool-jUnit
Slide đồ án kiểm thử PM
Giáo trình Tester Full
Đồ án kiểm thử phần mềm
Nunit framework for .NET application
Bao cao tttn an ninh web
Ad

Similar to Unit Testing Using N Unit (20)

PPT
SE2011_10.ppt
PPTX
Coded ui - lesson 1 - overview
ODP
Beginners - Get Started With Unit Testing in .NET
PPTX
Coded ui - lesson 4 - coded ui test
PDF
JUnit Testing Framework A Complete Guide.pdf
PDF
Game Programming 06 - Automated Testing
PDF
Modern Python Testing
DOC
Getting started with test complete 7
PPTX
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
PDF
YuryMakedonov_GUI_TestAutomation_QAI_Canada_2007_14h
PDF
Introduction To UnitTesting & JUnit
PPTX
Industrialization of Android Development (Concept)
DOC
Csharp Hands On Lab Paul Yao
ODP
Alexandre.iline rit 2010 java_fxui_extra
PPT
VB.Net GUI Unit_01
PPT
Unit Tests? It is Very Simple and Easy!
ODP
Plug yourself in and your app will never be the same (1 hr edition)
PDF
Writing Tests with the Unity Test Framework
PPTX
Improving Software Quality- 2-day Tester Training
PPTX
Inventory your network and clients with PowerShell
SE2011_10.ppt
Coded ui - lesson 1 - overview
Beginners - Get Started With Unit Testing in .NET
Coded ui - lesson 4 - coded ui test
JUnit Testing Framework A Complete Guide.pdf
Game Programming 06 - Automated Testing
Modern Python Testing
Getting started with test complete 7
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
YuryMakedonov_GUI_TestAutomation_QAI_Canada_2007_14h
Introduction To UnitTesting & JUnit
Industrialization of Android Development (Concept)
Csharp Hands On Lab Paul Yao
Alexandre.iline rit 2010 java_fxui_extra
VB.Net GUI Unit_01
Unit Tests? It is Very Simple and Easy!
Plug yourself in and your app will never be the same (1 hr edition)
Writing Tests with the Unity Test Framework
Improving Software Quality- 2-day Tester Training
Inventory your network and clients with PowerShell

More from Gaurav Arora (6)

PPTX
Test driven development
PPTX
ASP NET MVC Series For Beginers Part 2
PPTX
ASPNet MVC series for beginers part 1
PPTX
Asp net mvc series for beginers part 1
PPS
Silverlight Demos For Beginners
PPS
Wcf Transaction Handling
Test driven development
ASP NET MVC Series For Beginers Part 2
ASPNet MVC series for beginers part 1
Asp net mvc series for beginers part 1
Silverlight Demos For Beginners
Wcf Transaction Handling

Recently uploaded (20)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Encapsulation theory and applications.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Modernizing your data center with Dell and AMD
PPTX
A Presentation on Artificial Intelligence
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Cloud computing and distributed systems.
PPTX
Big Data Technologies - Introduction.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Dropbox Q2 2025 Financial Results & Investor Presentation
Per capita expenditure prediction using model stacking based on satellite ima...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Encapsulation theory and applications.pdf
Spectral efficient network and resource selection model in 5G networks
Building Integrated photovoltaic BIPV_UPV.pdf
Review of recent advances in non-invasive hemoglobin estimation
Modernizing your data center with Dell and AMD
A Presentation on Artificial Intelligence
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Understanding_Digital_Forensics_Presentation.pptx
Encapsulation_ Review paper, used for researhc scholars
Cloud computing and distributed systems.
Big Data Technologies - Introduction.pptx

Unit Testing Using N Unit

  • 1. Unit Testing using NunitIntroduction to Art of TestingPresenter:GauravAroraEmail: admin@hyderabadtechies.infoNote: This presentation is presented with courtesy of HyderabadTechies.info
  • 2. TopicsWhat is unit testing?Step-by-step OverviewWhat is Nunit?Hands-on using Nunit
  • 3. What is unit testing?Unit Testing is a way/method by which individual units of source code/application are tested to determine if they are fit for use.In other words, we can say method by which individual test one thing at a time [i.e. units] without touching external sources [DB, external files, libraries etc.]
  • 4. Who is responsible for testing?Primarily job for Unit Testing is completely for Developers. But, when we talk about Quality or testing then it would be a different answer.Everyone who is a developer
  • 5. Everyone who is a team member
  • 6. Even it’s the responsibility of customerMain benefits of unit testingMain goal of unit testing to make sure that each and every tested part [i.e. unit] is correct. In Test-Drive-application -Helpful in writing Smaller, tighter, decoupled code
  • 7. Helpful in Documentation of requirementsWhat do you need?Testing frameworkNUnit, MSTest, MbUnitTest runnerNUnit, MSTest, ReSharperMocking frameworkRhino Mocks, Moq, TypeMockWhy to choose NUnit?A generally asked question, there is a lengthy discussion and story for this, due to shortage of time, we can’t go with topic.Here are some links, go and grab the answer of this question :http://osherove.com/blog/2010/3/5/nunit-vs-mstest-nunit-wins-for-unit-testing.htmlhttp://stackoverflow.com/questions/3678783/mbunit-vs-nunithttp://stackoverflow.com/questions/261139/nunit-vs-mbunit-vs-mstest-vs-xunit-net
  • 8. What is Nunit?Nunit is unit-testing framework and supports all .Net languages. It has been written entirely in C# [csharp].Refer - http://www.nunit.org/
  • 9. Start with NunitBefore start, we need nUnit framework:Download from :http://www.nunit.org/index.php?p=downloadhttp://sourceforge.net/projects/nunit/[after download, install per your choice, not going in details of this chapter here…]For more info :http://www.nunit.org/
  • 10. Pictorial Flow of NunitnUnitDll, exe file XML file (Optional)Processing details on the GUI or Command promptImage : showing [Input & Output]
  • 11. Nunit : two operational flavorsNunit is having two operational modes:GUI modeGraphical user interface, nothing to type just click button and check the results.CUI [i.e. console] modeConsole mode, runs from command prompt, you need to write commands and check the results.
  • 12. Nunit : Hands-onBefore this make sure, nunit framework has been downloaded has properly installed at your system.Preferable, download Nunit-2.5.10.msi
  • 13. Add references to your project
  • 15. Run your tests either with GUI or CUI modeNunit : Hands-on… continue…In our Test project we are going to write simple test, which will test our methods for BMI application [a simple Body Mass Index calculator].Coming slides will tell step-by-step creation of project …
  • 16. Nunit : Hands-on… BMI TestStart your IDE to develop .Net application. In this session we are using VS2010
  • 17. Select a Class Library project [why choose class library, we are creating a separate project for our tests]
  • 18. Add reference of nunit.framework.dll in your project
  • 19. Include ‘NUnit.Framework’ namespace in your projectHands-on: BMI Test
  • 20. Hands-on: BMI Test-StructureUsingTestFixture AttributeTest ClassSetup attributeTearDown attributeTest attribute
  • 21. Hands-on : Points of interestIn previous slide we notified :Test class is named with *Tests
  • 22. Method names are long, defining scenarios
  • 23. Attribute TestFixture tells the fixture of test class
  • 24. Method with Setup attribute calls at very first and TearDown calls after every TestMethod, no matters if there will be an exceptionHands-on : ‘AAA’ methodNunit ‘AAA’ method is nothing butArrange :arrange objects, creating and setting them up as necessaryAct :Act on an objectAssertThat something is expected
  • 25. Lets take a look on Code!
  • 26. Nunit : CUIConsole mode is one of the modes available of Nunit, lets discuss how to run from command [console window]:The command to execute the exe in console mode is nunit-console.exe [filename] [option]
  • 27. Nunit : CUI - Output
  • 28. Nunit : CUI - Options*Options/Fixture=STR Fixture to test/config=STR project configuration to load/XML=STR Name of XML output file/transform=STR name of transform file/xmlConsoledisplay XML to the console/output=STR File to receive test output (short :/out=STR) /err=STR File to receive test error output/labels Label each test in stdout/include = STR list of categories to include/exclude = STR list of categories to exclude/noshadow disable shadow option/thread runs thread on a separate thread/wait waitfor input before closing console window /nologoDo not display the logo/help Display help (short format: /?)
  • 29. Nunit : GUI Go to your installed path of nunit framework and from bin folder select ‘nunit.exe’ If you installed nunit from msi package just go to program and select Nunit
  • 30. Nunit : Load Test
  • 31. Nunit : Test Result
  • 32. Lets take a look on Nunit GUI
  • 33. References“Art of Unit Testing” - Roy Osherove
  • 34. “Test-Driven Development in Microsoft .NET” – James Newkirk
  • 35. “Pragmatic Unit Testing in C# with NUnit” – Andy Hunt, Dave ThomasThanks