Download presentation
Presentation is loading. Please wait.
Published byLorena Arnold Modified over 8 years ago
1
Unit testing with NUnit Anne Lam & Chris James CMPS 4113 – Software Engineering April 15, 2015
2
Outline What is Unit Testing? Unit Testing Frameworks NUnit & how it works Conclusion
3
What is Unit Testing? Unit test - a code snippet written to test a piece of code – check if code meets its design and requirements behaves as expected Helps identify algorithm/logic failures
4
More on Unit Testing Written & executed by software developers Goal to segregate each part and test them individually Done before integration Considered white-box testing Use “assertions” to verify situations and conditions that we expect to occur
5
Manual vs. Unit Testing Manual tests require a tester to play role of end user – less efficient – not structured – not repeatable – not code comprehensive Unit tests – dramatically decrease the number of defects in code – improve design – are good documentation – reduce the cost of change – allow refactoring
6
Disadvantages of Unit Testing Can be time-consuming and tedious Demands patience and thoroughness from the development team Must maintain rigorous documentation May not be possible to test a unit for every input scenario that will occur in real-world environment
7
Good Unit Testing Is fully automated Can be run in any order if part of other tests Runs in memory (no DB or File access, for example) Returns the same result consistently Runs fast Tests a single logical concept in the system Is readable Is maintainable Is trustworthy (when you see its result, you don’t need to debug the code just to be sure)
8
Programming approaches Test-driven development (TDD) – Initially failing test case defines a new function – Minimum code produced to pass – Refactor to acceptable standards Extreme Programming – “if a little testing can eliminate a few flaws, a lot of testing can eliminate many more” – Get feedback through unit tests All code must have unit tests and must pass before it can be released.
9
Unit Testing Frameworks JUnit – first popular framework, based on Java NUnit – C# & all.NET languages cppUnit, jsUnit, PhpUnit => xUnit architecture All free
10
NUnit Open source Framework for Microsoft.Net Widely used and popular Created by Philip Craig Provides a class framework and a test runner application
11
Running NUnit Command Line NUnit plug-ins and extentions – Visual Studio or other IDE’s – NUnit Test Adapter (free) NUnit GUI – allow the selection of tests to be run, running them, and viewing the results
12
Demo Video https://www.youtube.com/watch?v=F9Y0mw po9j0&feature=youtu.be https://www.youtube.com/watch?v=F9Y0mw po9j0&feature=youtu.be
13
Conclusion on NUnit Allows effective unit testing with.NET applications Open-sourced & free Actively developed Testing leads to confidence, better code, and happier clients
14
References NUnit - Home. N.p., n.d. Web. 3 Apr. 2015. "Testando Seu Código C# Com NUnit - Parte I." C# Programmer. N.p., n.d. Web. 2 Apr. 2015. "What is Unit Testing? - Definition from WhatIs.com." SearchSoftwareQuality. N.p., n.d. Web. 2 Apr. 2015. "What is Unit Testing?" ISTQB Exam Certification – Study Material for Foundation Level, Through ISTQB and ASTQB Exam, Certification Questions, Answers, Tutorials and More. N.p., n.d. Web. 2 Apr. 2015. Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.