Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Unit Tests And Automated Testing

9,184 views

Published on

A short presentation on Unit Tests and Automated Testing

Published in: Technology
  • My daughter struggled with Maths due to an absence of teachers during year 10. I purchased Jeevan's 'home-tutor' program and she has not looked back. Not only does it explain the basic steps but also how to achieve those top grades. This is not only far better than a private tutor but amazing value for money. I would only have got a few hours of a tutors time for the same money. I am very grateful as this has turned my daughters attitude to Maths around- she now loves it and finds it easy! My other daughter, who is currently 14-years-old, has already begun your program. After going through your book and DVD's, she has moved up to the top set in maths. I have no doubt when she takes her GCSE maths in 2 years, she will achieve an A/A* grade! Many many thanks for your help Jeevan!  http://ishbv.com/jeevan91/pdf
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • After many failed attempts, I almost packed in my GCSE maths altogether. But fortunately I didn't, thanks to Jeevan's guide! When I read it, I found out exactly where I was going wrong all this time! I followed his approach and achieved 90% in my next sitting. I was shocked and I thought it was a total fluke so I put his strategy to the test again. This time, I got 100%! Fantastic! If only I came across Jeevan's strategy sooner. Learn more.. ➤➤ http://t.cn/AirrSv7D
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Substandard data quality is harming organizations to an immense extent. Inaccurate and erroneous data impacts organizations with budget increments, customer displeasure, and organizational uncertainty. This is where automation testing can resolve the vulnerability by verifying the data. http://bit.ly/2NKhy1xa
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • The third slide has worth a full day of study
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

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 />

×