Presentation is loading. Please wait.

Presentation is loading. Please wait.

Test Driven Development and NUnit Testing -Adam Main.

Similar presentations


Presentation on theme: "Test Driven Development and NUnit Testing -Adam Main."— Presentation transcript:

1 Test Driven Development and NUnit Testing -Adam Main

2 What is Test Driven Development? b 2 Rules Write new code only when a test failsWrite new code only when a test fails Eliminate duplicationEliminate duplication b Failing to compile is failing a test

3 Basic Process 1. Write a test that fails 2. Write code to pass the test 3. Refactor the code 4. If the program isn’t finished, goto 1

4 Advantages b Concise and simple b Less manual testing b Know specs and requirements b Higher percent code coverage b Highly testable code b Coupling and cohesion

5 Disadvantages b High number of compiles Wastes timeWastes time Less thoughtLess thought b Very little design 15-20 minutes15-20 minutes LanguageLanguage HardwareHardware

6 What is NUnit? b Based off of xUnit JUnit -JavaJUnit -Java b Basic testing framework b.NET environment b Uses metadata b Console and GUI testing apps

7 Why NUnit? b Simple Interface b Constant Feedback b XML results b Configurable SubsetsSubsets PackagesPackages SolutionsSolutions

8 How do you use NUnit? b Metadata attribute tags b Assert library calls b GUI or console application

9 What are Attribute tags? b.NET b [Attribute] b Metadata b “Compilable comments”

10 Attribute Tags b [TestFixture] b [Test] b [TestFixtureSetUp] b [TestFixtureTearDown]

11 More Attribute Tags b [ExpectedException(typeof(ExceptionType))] b [Category("Category Name")] b [Explicit] b [Ignore(“reason”)]

12 What is the Assert Library b Created by NUnit team b Static functions b Assert class

13 Assert Functions b 3 Basic Overloads -Assert.IsFalse( bool condition); -Assert.IsFalse( bool condition, string message ); -Assert.IsFalse( bool condition, string message, object[] parms ); b One Assert per test Short circuitShort circuit Simple and concise testsSimple and concise tests

14 Assert Functions  AreEqual(int actual, int expected)  AreEqual(double actual, double expected)  AreEqual(float actual, float expected)  AreEqual(decimal actual, decimal expected)  AreEqual(object actual, object expected)  AreSame (object actual, object expected)

15 Assert Functions  IsTrue( bool condition)  IsFalse( bool condition)  IsNull( object obj)  IsNotNull( object obj)  Fail()  Ignore()

16 Projects b Load VS projects/solutions b Save selected tests b.nunit

17 Demo b Create a simple b Use TDD b Use NUnit

18 Sources b [1] NUnit - Documentation. Retrieved March 28, 2005, from http://nunit.org/documentation.html b [2] George, Boby and Laurie Williams. An Initial Investigation of Test Driven Development in Industry. Retrieved March 30, 2005, from http://collaboration.csc.ncsu.edu/laurie/Papers/TDDpaperv8.pdf b [3] Ganssle, Jack. XP Deconstructed. Dec 10, 2003. http://www.embedded.com/showArticle.jhtml?articleID=16700086 b [4] Provost, Peter. Test Driven Development in.NET. http://www.codeproject.com/dotnet/tdd_in_dotnet.asp b [5] Introduction to Test Drive Development (TDD). Retreived April 1, 2005, from http://www.agiledata.org/essays/tdd.html b [6] Mugridge, Rick. Test Driven Development and the Scientific Method. http://www.agiledevelopmentconference.com/2003/files/P6Paper.pdf


Download ppt "Test Driven Development and NUnit Testing -Adam Main."

Similar presentations


Ads by Google