Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

FoxUnit in Depth.pptx

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Nächste SlideShare
Unit Testing
Unit Testing
Wird geladen in …3
×

Hier ansehen

1 von 29 Anzeige

Weitere Verwandte Inhalte

Ähnlich wie FoxUnit in Depth.pptx (20)

Anzeige

Aktuellste (20)

FoxUnit in Depth.pptx

  1. 1. FoxUnit in Depth Eric Selje
  2. 2. About this session Unit Testing and How to Do It Level: Anyone who wants to code better Pre-requisites: Have written code with bugs at any time in your career.
  3. 3. FoxUnit in Depth Eric Selje Madison, WI @EricSelje Salty Dog Solutions, LLC Database Developer General IT Guy
  4. 4. Agenda You will learn: o What unit testing is o What unit testing is NOT o What is FoxUnit o How to Run Unit Tests in FoxUnit
  5. 5. Goal By the end of this session you should be very eager and very comfortable with how to create Unit Tests in FoxUnit.
  6. 6. What is “Unit Testing?” • Code that “tests” your application’s code • Tests ensure your code does what you expect
  7. 7. You have already done this
  8. 8. Reason This is Bad #1: Designed for Success
  9. 9. Reason This is Bad#2: Ephemeral
  10. 10. Reason This is Bad# 3: Manual
  11. 11. Rules for Good Unit Tests Don’t be afraid to fail! You’re testing the robustness of your code. It doesn’t make sense to only write tests for normal expectations.
  12. 12. Rules for Good Unit Tests Multiple Tests per Method Multiple Tests per Method Multiple Tests per Method Multiple Tests per Method Multiple Tests per Method
  13. 13. Rules for Good Unit Tests Each class that you’re testing should be in its own “test class.”
  14. 14. Rules for Good Unit Tests Code stuck in event methods and other parts of the GUI are UNTESTABLE.
  15. 15. Write Testable Code Use Business Objects • Keep your methods focused on a single task Don’t put any code in GUI except code for the user interface • Forms • Controls (Buttons, TextBoxes) • Events (Click(), LostFocus())
  16. 16. Rules for Good Unit Tests Test One Thing at a Time
  17. 17. Rules for Good Unit Tests Quick! Easy to Read
  18. 18. FoxUnit FRAMEWORK for unit testing within Visual FoxPro • Manages our Test Classes • Makes tests easy to run and parse results • Can be part of a Continuous Integration system Has been around since 2004
  19. 19. Installing FoxUnit VFPx  Subversion Download from Releases Page https://vfpx.svn.codeplex.com/svn/FoxUnit.
  20. 20. Installing FoxUnit Thor • AutoUpdates • Toolbar • Hot Key
  21. 21. FoxUnit Demo  Tour of FoxUnit  Configuration Options  Creating Test Classes and Tests  Running Tests  Command Line
  22. 22. FoxUnit Demo Class to Test = String Emulates C#’s String Class String.Format(“Hello, {0}!”, “Phoenix”)
  23. 23. Strategy Old Code: Before you refactor, write unit tests New Code: Start doing Test Driven Development
  24. 24. Test Driven Development Write tests FIRST for all new functionality e.g. String.Concat(“Hello”, “Phoenix”) String.Remove(“Mississippi”, “iss”)
  25. 25. Continuous Integration AUTOMATE your unit tests The Continuous Integration Cycle
  26. 26. Continuous Integration Add this to whatever CI system you use: Vfp9.exe -t -a –c<path>config.fpw <path>FoxUnitFXU.prg createFxuResultsAddAllTestsAndRun
  27. 27. Continuous Integration Results stored in  Results.xml  DetailedResults.txt  Foxunit.Debug.txt Parse your results
  28. 28. Goal? Are you eager and comfortable with how to create Unit Tests in FoxUnit?
  29. 29. Thank You Sponsors!  They are Awesome  Visit Their Booths and Talk with Them Remember to fill out your evaluation. Session white paper and code samples will be updated in perpetuity.

×