SlideShare a Scribd company logo
Unit Testing
Gayani Tennakoon
Software Engineer@ 99XTechnology
The partner of choice for ISV's
Plan for Today
• What is Unit Testing
• Why Unit Tests
• Best Practices for effective Unit Testing
• Considerations in Unit Testing
• Nunit overview
• Writing Unit Tests – Practical Session
• Exercise..
The partner of choice for ISV's
What is Unit Testing
The partner of choice for ISV's
Unit Testing
• Developers do unit testing
• Write a code to test a small specific area of functionality
• It helps to prove the functionality
The partner of choice for ISV's
Why Unit Tests
• Better Code
• Better Design
• Code is easier to maintain later
• Confidence when you code
• Make your life easy
The partner of choice for ISV's
Best Practices for Effective Unit Testing
• Use Good Tools
Testing Focused Tools –Nunit, MsTest,Test Driven .NET
Supporting Tools -Ms Build, Resharper
• Use a Test List
• Get a Mentor
• Automate Your Test Execution
The partner of choice for ISV's
Considerations in Unit Testing
 What to test
You need to answer
“If the code ran correctly, how would I know?”
You can test
• Test at the boundaries
• Test every error message
• Test different configurations
• Run tests that are annoying to setup
• Avoid redundant tests
The partner of choice for ISV's
Considerations in Unit Testing
 Test Structure
William Wake’s 3-A Pattern
– Arrange
– Act
– Assert
 Designing For Test
“How am I going to test this ?”
The partner of choice for ISV's
Nunit Overview
• Open source Unit Testing framework
• Attributes
• indicate test classes and methods
• modify behavior of classes and methods
• Assertions
• test an actual value against expected value
The partner of choice for ISV's
Nunit Overview
[TestFixture]
public class TestFixtureLifetime
{
[TestFixtureSetUp]
public void BeforeTest()
{
// single set of functions that are performed once prior to executing any of the tests in the text fixture
}
[TestFixtureTearDown]
public void AfterTest()
{
// single set of functions that are performed once after to executing any of the tests in the text fixture
}
[Test]
public void Test1()
{
int expectedResult=4;
int actualResult =squareRoot(16);
Assert.AreEqual(expectedResult,actualResult,”Error Message”)
}
}
The partner of choice for ISV's
Nunit Overview
• Learn more about Nunit
go to http://www.nunit.org
The partner of choice for ISV's
Its Time To Write Some Unit Tests
The partner of choice for ISV's
Exercise
• Write a program that prints the numbers from 1 to 100. But
for multiples of three print “Fizz” instead of the number and
for the multiples of five print “Buzz”. For numbers which are
multiples of both three and five print “FizzBuzz”.
• Write unit tests for your implementation
• You will be given 15 min.
The partner of choice for ISV's
References
 http://bradwilson.typepad.com/presentations/effe
ctive-unit-testing.pdf
 http://www.testdriven.com
 http://www.xprogramming.com
 http://workspaces.gotdotnet.com/tdd
The partner of choice for ISV's
References
• The Pragmatic Programmer
Andy Hunt and Dave Thomas
• Test-Driven Development in Microsoft .NET
Jim Newkirk and Alexei Vorontsov
• Test-Driven Development, by Example
Kent Beck
• Pragmatic Unit Testing in C# with NUnit
Andy Hunt and Dave Thomas
• Working Effectively With Legacy Code
Michael Feathers
• Refactoring
Martin Fowler
• Lessons Learned in Software Testing
Cem Kaner, James Bach, and Brett Pettichord
The partner of choice for ISV's
Thank You !

More Related Content

PDF
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...
PPT
Introduction to software testing
PDF
DIG1108C Lesson 7 Fall 2014
PPTX
Unit testing and mocking in Python - PyCon 2018 - Kenya
PPTX
Project Onion unit test environment
PDF
Win at life with unit testing
PPTX
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...
Introduction to software testing
DIG1108C Lesson 7 Fall 2014
Unit testing and mocking in Python - PyCon 2018 - Kenya
Project Onion unit test environment
Win at life with unit testing
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)

What's hot (20)

PDF
Testing in java
PPTX
Test Driven Development
PPTX
Qa process 2012
PPTX
Mihai mahulea the zen of test driven development
PPTX
Tdd for php
PPTX
Salient tips for writing effective test cases
PDF
QA Process Overview for Firefox OS 2014
PPT
Fitnesse Testing Framework
PPTX
The Art of Testing Less without Sacrificing Quality @ ICSE 2015
PPTX
Unit Testing in Action - C#, NUnit, and Moq
PDF
Test Driven Development
PPT
1.microsoft visual studio 2010 test manager
PPTX
Code review prediction
PPTX
Automation testing
PPTX
ISTQB Foundation Agile Tester 2014 Training, Agile SW Development
PPTX
Testing
PPTX
Why Automated Testing Matters To DevOps
PDF
Continuous Integration Approach
PPT
Test automation in agile ecosystem
Testing in java
Test Driven Development
Qa process 2012
Mihai mahulea the zen of test driven development
Tdd for php
Salient tips for writing effective test cases
QA Process Overview for Firefox OS 2014
Fitnesse Testing Framework
The Art of Testing Less without Sacrificing Quality @ ICSE 2015
Unit Testing in Action - C#, NUnit, and Moq
Test Driven Development
1.microsoft visual studio 2010 test manager
Code review prediction
Automation testing
ISTQB Foundation Agile Tester 2014 Training, Agile SW Development
Testing
Why Automated Testing Matters To DevOps
Continuous Integration Approach
Test automation in agile ecosystem
Ad

Similar to Unit Testing (20)

PDF
An Introduction to Unit Test Using NUnit
PDF
Sencha Roadshow 2017: Best Practices for Implementing Continuous Web App Testing
PDF
May: Automated Developer Testing: Achievements and Challenges
PPTX
Unit tests & TDD
PPTX
An Introduction to Unit Testing
PPTX
Tools for Software Testing
PPTX
Istqb foundation level day 1
PPTX
Episode 5 - Writing unit tests in Salesforce
PPTX
A Beginer's Guide to testing in Django
PDF
Agile Acceptance testing with Fitnesse
PPTX
Database Unit Testing Made Easy with VSTS
PPTX
Automated Testing Tutorial
PPTX
software testing
PDF
ST-All about Test Case-p3
PDF
St all about test case-p3
PPTX
Unit testing & TDD concepts with best practice guidelines.
PDF
Testing Angular
PDF
Introduction to-automated-testing
PDF
Introduction to Automated Testing
PPTX
Unit testing
An Introduction to Unit Test Using NUnit
Sencha Roadshow 2017: Best Practices for Implementing Continuous Web App Testing
May: Automated Developer Testing: Achievements and Challenges
Unit tests & TDD
An Introduction to Unit Testing
Tools for Software Testing
Istqb foundation level day 1
Episode 5 - Writing unit tests in Salesforce
A Beginer's Guide to testing in Django
Agile Acceptance testing with Fitnesse
Database Unit Testing Made Easy with VSTS
Automated Testing Tutorial
software testing
ST-All about Test Case-p3
St all about test case-p3
Unit testing & TDD concepts with best practice guidelines.
Testing Angular
Introduction to-automated-testing
Introduction to Automated Testing
Unit testing
Ad

More from Dotitude (12)

PPTX
Career Paths for IT Graduates
PPTX
MEAN Stack
PPTX
How To Make A Good Resume
PPTX
Introduction to Hybrid Application Development
PPTX
Hybrid App Development with PhoneGap
PPTX
Beyond Tomorrow
PDF
Cloud Ready Apps
PPTX
Connecting Dots - Preparing for future
PPTX
Evolution Towards Agile
PPTX
Industry Expectations
PPTX
Software Product Engineering Life-cycle
PPTX
Managing Your Online Presence
Career Paths for IT Graduates
MEAN Stack
How To Make A Good Resume
Introduction to Hybrid Application Development
Hybrid App Development with PhoneGap
Beyond Tomorrow
Cloud Ready Apps
Connecting Dots - Preparing for future
Evolution Towards Agile
Industry Expectations
Software Product Engineering Life-cycle
Managing Your Online Presence

Recently uploaded (20)

PDF
Salesforce Agentforce AI Implementation.pdf
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Download FL Studio Crack Latest version 2025 ?
PDF
Nekopoi APK 2025 free lastest update
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Cost to Outsource Software Development in 2025
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Salesforce Agentforce AI Implementation.pdf
17 Powerful Integrations Your Next-Gen MLM Software Needs
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Download FL Studio Crack Latest version 2025 ?
Nekopoi APK 2025 free lastest update
wealthsignaloriginal-com-DS-text-... (1).pdf
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
iTop VPN Crack Latest Version Full Key 2025
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
Design an Analysis of Algorithms II-SECS-1021-03
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Navsoft: AI-Powered Business Solutions & Custom Software Development
Monitoring Stack: Grafana, Loki & Promtail
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Cost to Outsource Software Development in 2025
Oracle Fusion HCM Cloud Demo for Beginners
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Patient Appointment Booking in Odoo with online payment
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025

Unit Testing

  • 1. Unit Testing Gayani Tennakoon Software Engineer@ 99XTechnology
  • 2. The partner of choice for ISV's Plan for Today • What is Unit Testing • Why Unit Tests • Best Practices for effective Unit Testing • Considerations in Unit Testing • Nunit overview • Writing Unit Tests – Practical Session • Exercise..
  • 3. The partner of choice for ISV's What is Unit Testing
  • 4. The partner of choice for ISV's Unit Testing • Developers do unit testing • Write a code to test a small specific area of functionality • It helps to prove the functionality
  • 5. The partner of choice for ISV's Why Unit Tests • Better Code • Better Design • Code is easier to maintain later • Confidence when you code • Make your life easy
  • 6. The partner of choice for ISV's Best Practices for Effective Unit Testing • Use Good Tools Testing Focused Tools –Nunit, MsTest,Test Driven .NET Supporting Tools -Ms Build, Resharper • Use a Test List • Get a Mentor • Automate Your Test Execution
  • 7. The partner of choice for ISV's Considerations in Unit Testing  What to test You need to answer “If the code ran correctly, how would I know?” You can test • Test at the boundaries • Test every error message • Test different configurations • Run tests that are annoying to setup • Avoid redundant tests
  • 8. The partner of choice for ISV's Considerations in Unit Testing  Test Structure William Wake’s 3-A Pattern – Arrange – Act – Assert  Designing For Test “How am I going to test this ?”
  • 9. The partner of choice for ISV's Nunit Overview • Open source Unit Testing framework • Attributes • indicate test classes and methods • modify behavior of classes and methods • Assertions • test an actual value against expected value
  • 10. The partner of choice for ISV's Nunit Overview [TestFixture] public class TestFixtureLifetime { [TestFixtureSetUp] public void BeforeTest() { // single set of functions that are performed once prior to executing any of the tests in the text fixture } [TestFixtureTearDown] public void AfterTest() { // single set of functions that are performed once after to executing any of the tests in the text fixture } [Test] public void Test1() { int expectedResult=4; int actualResult =squareRoot(16); Assert.AreEqual(expectedResult,actualResult,”Error Message”) } }
  • 11. The partner of choice for ISV's Nunit Overview • Learn more about Nunit go to http://www.nunit.org
  • 12. The partner of choice for ISV's Its Time To Write Some Unit Tests
  • 13. The partner of choice for ISV's Exercise • Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”. • Write unit tests for your implementation • You will be given 15 min.
  • 14. The partner of choice for ISV's References  http://bradwilson.typepad.com/presentations/effe ctive-unit-testing.pdf  http://www.testdriven.com  http://www.xprogramming.com  http://workspaces.gotdotnet.com/tdd
  • 15. The partner of choice for ISV's References • The Pragmatic Programmer Andy Hunt and Dave Thomas • Test-Driven Development in Microsoft .NET Jim Newkirk and Alexei Vorontsov • Test-Driven Development, by Example Kent Beck • Pragmatic Unit Testing in C# with NUnit Andy Hunt and Dave Thomas • Working Effectively With Legacy Code Michael Feathers • Refactoring Martin Fowler • Lessons Learned in Software Testing Cem Kaner, James Bach, and Brett Pettichord
  • 16. The partner of choice for ISV's Thank You !