Unit Tests & Automated Testing<br />Lee Englestone presents..<br />www.manchesterdeveloper.com<br />
Agenda<br />Terminology<br />What, Why, How<br />Automating unit tests & testing<br />Advanced stuff<br />Test driven deve...
Terminology (for the next hour)<br />Unit test<br />Tests a small bit of code (from code)<br />Integration test<br />Test ...
Why should we TEST?<br />Why should we test at all?<br />£<br />£<br />REMEMBER<br />Testing is just one step in QA<br />£...
Testing different layers<br />Business Logic<br />Unit Tests<br />Web UI<br />Selenium<br />
Three tier architecture<br />Web UI<br />ASPX, ASCX, HTML, Flash,<br />EpiServer Page Templates etc<br />Business Logic<br...
Testing business logic<br />Code libraries (DLLs)<br />Business Logic (DLL)<br />Unit Tests (DLL)<br />Unit Tests (DLLs)<b...
Why have unit tests?<br />Why have unit tests?<br />Find bugs early / fast feedback<br />Increase QA<br />Why not to have ...
Unit Testing <br />is not a Silver Bullet<br />
What is a unit test?<br />“..tests if individual units of source code are fit for use.”<br />Should be<br />Small<br />Spe...
What does a unit test look like? <br />Using NUnit.Framework;<br />[TestFixture]<br />public class CarTests<br />{<br />	[...
Example unit test : Running<br />Running unit tests manually with NUnit<br />
An example scenario<br />{ Code Example }<br />Objects<br />Car<br />Properties<br />ColorColor<br />double Value<br />dou...
Automating unit testing<br />
Testing Web UI (Selenium)<br />What if we want to test the UI?<br /> Manual recording and running<br />Can export to NUnit...
Test driven development (TDD)<br />Write your tests, even BEFORE your code!<br />Make sure all tests initially fail<br />T...
Code coverage<br />What % of your code base are you testing?<br />
Summary	<br />Test as early as possible<br />Design code to test<br />Separate BL from UI<br />Improve QA<br />Make unit t...
Appendixes<br />Wikipedia testing definitions <br />
Testing Terminology (Wikipedia)<br />Unit test<br />“..a programmer tests if individual units of source code are fit for u...
Upcoming SlideShare
Loading in...5
×

Unit Tests And Automated Testing

5,334

Published on

A short presentation on Unit Tests and Automated Testing

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,334
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
108
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • There are no silver bullets in development.Developers have are there disposal an arsenal tools, and they must be used in the right way to fit company processes
  • Unit Tests And Automated Testing

    1. 1. Unit Tests & Automated Testing<br />Lee Englestone presents..<br />www.manchesterdeveloper.com<br />
    2. 2. Agenda<br />Terminology<br />What, Why, How<br />Automating unit tests & testing<br />Advanced stuff<br />Test driven development (TDD)<br />Code coverage<br />What we wont be covering<br />Continuous Integration (in any depth) <br />
    3. 3. Terminology (for the next hour)<br />Unit test<br />Tests a small bit of code (from code)<br />Integration test<br />Test after addition of code<br />System test / functional test<br />Test for adherence to user requirements <br />Regression test<br />Test that fixing / adding code hasn’t introduced bugs<br />Continuous integration<br />Automated checkout, building and testing of code from source control<br />Source : Lee & Wikipedia<br />
    4. 4. Why should we TEST?<br />Why should we test at all?<br />£<br />£<br />REMEMBER<br />Testing is just one step in QA<br />£<br />£<br />£<br />£<br />£<br />
    5. 5. Testing different layers<br />Business Logic<br />Unit Tests<br />Web UI<br />Selenium<br />
    6. 6. Three tier architecture<br />Web UI<br />ASPX, ASCX, HTML, Flash,<br />EpiServer Page Templates etc<br />Business Logic<br />Code libraries (DLLs)<br />Business Logic (DLL)<br />Database access<br />Data Access Layer<br />
    7. 7. Testing business logic<br />Code libraries (DLLs)<br />Business Logic (DLL)<br />Unit Tests (DLL)<br />Unit Tests (DLLs)<br />Database access<br />Data Access Layer<br />
    8. 8. Why have unit tests?<br />Why have unit tests?<br />Find bugs early / fast feedback<br />Increase QA<br />Why not to have unit tests<br />Increases development time?<br />CostOfWritingUnitTests < Sum(BugFixing)<br />
    9. 9. Unit Testing <br />is not a Silver Bullet<br />
    10. 10. What is a unit test?<br />“..tests if individual units of source code are fit for use.”<br />Should be<br />Small<br />Specific (only test 1 thing)<br />Clear pass / fail criteria<br />
    11. 11. What does a unit test look like? <br />Using NUnit.Framework;<br />[TestFixture]<br />public class CarTests<br />{<br /> [Test]<br /> public void Test_Car_Paint () <br /> {<br /> // Arrange<br />Color paint = Color.Red;<br /> Car car = new Car();<br /> // Act<br />car.paint(Color.Red);<br /> // Assert<br />Assert.AreEqual(car.Color, paint);<br /> }<br /> …<br />}<br />Arrange<br />Act<br />Assert<br />
    12. 12. Example unit test : Running<br />Running unit tests manually with NUnit<br />
    13. 13. An example scenario<br />{ Code Example }<br />Objects<br />Car<br />Properties<br />ColorColor<br />double Value<br />double FuelLevel<br />double FuelCapacity<br />FuelTypeEnumFuelType<br />Methods<br />Car.Crush()<br />Car.Paint(Color)<br />Car.AddFuel(FuelTypeEnum, double)<br />Car.VeryImportantMethod()<br />
    14. 14. Automating unit testing<br />
    15. 15. Testing Web UI (Selenium)<br />What if we want to test the UI?<br /> Manual recording and running<br />Can export to NUnit<br />Examples : <br />Community Fund Form<br />H1 checking**<br />{ Code Example }<br />
    16. 16. Test driven development (TDD)<br />Write your tests, even BEFORE your code!<br />Make sure all tests initially fail<br />Then implement the code that the tests are testing<br />(Encourages Designing for Testing)<br />
    17. 17. Code coverage<br />What % of your code base are you testing?<br />
    18. 18. Summary <br />Test as early as possible<br />Design code to test<br />Separate BL from UI<br />Improve QA<br />Make unit tests part of CI<br />
    19. 19.
    20. 20. Appendixes<br />Wikipedia testing definitions <br />
    21. 21. Testing Terminology (Wikipedia)<br />Unit test<br />“..a programmer tests if individual units of source code are fit for use.”<br />Integration test<br />“..individual software modules are combined and tested as a group. It occurs after unit testing and before system testing.”<br />System test / functional test<br />“..testing conducted on a complete, integrated system to evaluate the system's compliance with its specified requirements. <br />Regression test<br />“..seeks to uncover software errors by partially retesting a modified program. The intent of regression testing is to assure that a bug fix has been successfully corrected .. , while providing a general assurance that no other errors were introduced in the process of fixing the original problem.”<br />Continuous integration<br />Automated checkout, building and testing of code from source control<br />Source : Wikipedia<br />
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×