unit tests and automated testing

Download Unit Tests And Automated Testing

Post on 22-Nov-2014




2 download

Embed Size (px)


A short presentation on Unit Tests and Automated Testing


  • 1. Unit Tests & Automated Testing
    Lee Englestone presents..
  • 2. Agenda
    What, Why, How
    Automating unit tests & testing
    Advanced stuff
    Test driven development (TDD)
    Code coverage
    What we wont be covering
    Continuous Integration (in any depth)
  • 3. Terminology (for the next hour)
    Unit test
    Tests a small bit of code (from code)
    Integration test
    Test after addition of code
    System test / functional test
    Test for adherence to user requirements
    Regression test
    Test that fixing / adding code hasnt introduced bugs
    Continuous integration
    Automated checkout, building and testing of code from source control
    Source : Lee & Wikipedia
  • 4. Why should we TEST?
    Why should we test at all?

    Testing is just one step in QA

  • 5. Testing different layers
    Business Logic
    Unit Tests
    Web UI
  • 6. Three tier architecture
    Web UI
    ASPX, ASCX, HTML, Flash,
    EpiServer Page Templates etc
    Business Logic
    Code libraries (DLLs)
    Business Logic (DLL)
    Database access
    Data Access Layer
  • 7. Testing business logic
    Code libraries (DLLs)
    Business Logic (DLL)
    Unit Tests (DLL)
    Unit Tests (DLLs)
    Database access
    Data Access Layer
  • 8. Why have unit tests?
    Why have unit tests?
    Find bugs early / fast feedback
    Increase QA
    Why not to have unit tests
    Increases development time?
    CostOfWritingUnitTests < Sum(BugFixing)
  • 9. Unit Testing
    is not a Silver Bullet
  • 10. What is a unit test?
    ..tests if individual units of source code are fit for use.
    Should be
    Specific (only test 1 thing)
    Clear pass / fail criteria
  • 11. What does a unit test look like?
    Using NUnit.Framework;
    public class CarTests
    public void Test_Car_Paint ()
    // Arrange
    Color paint = Color.Red;
    Car car = new Car();
    // Act
    // Assert
    Assert.AreEqual(car.Color, paint);

  • 12. Example unit test : Running
    Running unit tests manually with NUnit
  • 13. An example scenario
    { Code Example }
    double Value
    double FuelLevel
    double FuelCapacity
    Car.AddFuel(FuelTypeEnum, double)
  • 14. Automating unit testing
  • 15. Testing Web UI (Selenium)
    What if we want to test the UI?
    Manual recording and running
    Can export to NUnit
    Examples :
    Community Fund Form
    H1 checking**
    { Code Example }
  • 16. Test driven development (TDD)
    Write your tests, even BEFORE your code!
    Make sure all tests initially fail
    Then implement the code that the tests are testing
    (Encourages Designing for Testing)
  • 17. Code coverage
    What % of your code base are you testing?
  • 18. Summary
    Test as early as possible
    Design code to test
    Separate BL from UI
    Improve QA
    Make unit tests part of CI
  • 19.
  • 20. Appendixes
    Wikipedia testing definitions
  • 21. Testing Terminology (Wikipedia)
    Unit test
    ..a programmer tests if individual units of source code are fit for use.
    Integration test
    ..individual software modules are combined and tested as a group. It occurs after unit testing and before system testing.
    System test / functional test
    ..testing conducted on a complete, integrated system to evaluate the system's compliance with its specified requirements.
    Regression test
    ..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.
    Continuous integration
    Automated checkout, building and testing of code from source control
    Source : Wikipedia


View more >