Advertisement
Guest User

Cucumber in Koha tutorial

a guest
May 26th, 2015
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. +--<>--<>--<>--<>-<>--<>--<>--<>--+
  2. <> Writing Cucumber tests for Koha <>
  3. +--<>--<>--<>--<>-<>--<>--<>--<>--+
  4.  
  5. +---
  6. | Cucumber tests are split into 4 different types of files: )==>
  7. +---
  8.  
  9. 1. Feature definitions, features/*/*.feature
  10. These are the user stories which trigger the Cucumber steps.
  11.  
  12. 2. step-definitions, steps/*_steps.pl
  13. These files define the Cucumber steps and depend only on the step implementations to mimize coupling.
  14.  
  15. 3. step implementations, SImpls/*/*.pm
  16. These files implement the steps defined in steps-folder, which are not using browser tests. This is all
  17. back-end stuff, like cronjobs, basic CRUD for features, etc.
  18.  
  19. 4. Page Objects, POs/*/*.pm
  20. These files implement the browser based steps which test interface functionality.
  21.  
  22.  
  23. +---
  24. | Tests are structured into the following organization: )==>
  25. +---
  26.  
  27. Step-files can be easily moved around so for now we can just put them in the steps-folder.
  28. t/Cucumber/steps/borrower_steps.pl
  29. t/Cucumber/steps/borrower_rest_steps.pl
  30. t/Cucumber/steps/borrower_po_steps.pl
  31. t/Cucumber/steps/issue_steps.pl
  32. t/Cucumber/steps/biblio_rest_steps.pl
  33.  
  34. A Cucumber best-practice is to separate code from the step definitions, and with the step
  35. implementations we mimick the Koha module hierarchy.
  36. t/Cucumber/SImpls/Borrowers/Borrowers.pm
  37. t/Cucumber/SImpls/Borrowers/MessagePreferences.pm
  38. t/Cucumber/SImpls/FloatingMatrix/FloatingMatrix.pm
  39.  
  40. To test the web pages, we should use a Page Object Pattern, in which each page, like
  41. members/memberentry.pl gets it's own matching object to abstract the HTML elements under
  42. object methods. Thus writing tests is much easier and features are encapsulated better. So it
  43. is easier to maintain interface tests when change happens.
  44. Here we mimic the Koha-controllers hierarchy with the goal of each Page Object matching a Koha controller,
  45. like members/memberentry.pl
  46. t/Cucumber/POs/Borrowers/MemberEntry.pm
  47. t/Cucumber/POs/Borrowers/Member.pm
  48. t/Cucumber/POs/Borrowers/PrintSlip.pm
  49. t/Cucumber/POs/Biblios/AddBiblio.pm
  50. (we can put REST tests object first like "POs/Borrowers/RESTv1.pm" as an alternative)
  51. t/Cucumber/POs/REST/v1/Biblios.pm
  52. t/Cucumber/POs/REST/v1/Borrowers.pm
  53.  
  54. Feature definitions are easily movable to another hierarchy, so we just for now gather them
  55. under top-level modules.
  56. t/Cucumber/features/Overdues/calendarCRUD.feature
  57. t/Cucumber/features/Overdues/printProviderLimbo.feature
  58. t/Cucumber/features/Borrowers/borrowersCRUD.feature
  59. t/Cucumber/features/FloatingMatrix/floatingMatrixCRUD.feature
  60. t/Cucumber/features/FloatingMatrix/floatingMatrix.feature
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement