Vorlage für Automatisiertes Testen mit der Programmiersprache C
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.4 KiB

1 year ago
  1. # Testen in der Programmiersprache C
  2. ## Voraussetzungen
  3. ### Benötigte Software
  4. #### auf ihrem privaten Rechner
  5. - Installieren Sie das Build-Tool `ceedling` (http://www.throwtheswitch.org/ceedling)
  6. - installieren Sie Ruby (https://www.ruby-lang.org/en/downloads/)
  7. #### privat oder Labor
  8. clonen sie folgende Projekte von Github in einem Ordner parallel zu Ihren C-Projekten.
  9. > Zielstruktur:
  10. >
  11. > */Projekte
  12. > +- CMock
  13. > +- Unity
  14. > +- Projekt1
  15. > +- Projekt2
  16. > ...
  17. - *Unity* (Testing-Framework) https://github.com/ThrowTheSwitch/Unity
  18. - *CMock* https://github.com/ThrowTheSwitch/CMock
  19. - im Verzeichnis CMock dieses Kommando ausführen:
  20. `bundle install`
  21. ### Übungsprojekt
  22. - dieses Projekt in ein Verzeichnis parallel zu *Unity* und *CMock* clonen
  23. - Offnen Sie die Datei `src/test/c/test_berechnung.c` in einem Editor
  24. - Verwenden Sie das `TEST_ASSERT_EQUAL_STRING` Macro aus dem *Unity* Framework für folgende Testfälle für die Methode `convert()`:
  25. 1. 2 -> "2"
  26. 1. 3 -> "Fizz"
  27. 1. 5 -> "Buzz"
  28. 1. 11 -> "11"
  29. 1. 15 -> "FizzBuzz"
  30. 1. 12 -> "12" (schlägt fehl)
  31. - Verwenden Sie das `TEST_ASSERT_EQUAL_INT` Macro aus dem *Unity* Framework für folgende Testfälle für die Methode `gcd()`:
  32. 1. 15, 20 -> 5
  33. 1. 183, 99 -> 3
  34. 1. 91, 1008 -> 7
  35. - Ergänzen Sie die *asserts* um eine Bechreibung mit dem Macro `TEST_ASSERT_EQUAL_INT_MESSAGE` bzw. `TEST_ASSERT_EQUAL_STRING_MESSAGE`