2017-10-27 October learning session

Date

Attendees

Goals

Discussion

The material presented four patterns and demos on what problems the pattern can solve and how to refactor the existing code to use the pattern. Out of those four, we have chosen three to watch and discuss:

  • Object Mother / Fluent Builder
  • SUT Mother / SUT Builder
  • Fixture Object


Is this something that we had problems with / can be useful in OpenLMIS?


Could this pattern be applied to UI tests as well / is this also a problem in UI tests?

  • Yes - there's a lot of code duplication both with test objects and mocking the same behaviour in multiple places
  • Usually the objects created are not very representative - they only contain one or two properties set (eg. "id" and "code") which are necessary for the given test; it would be better if those were complete objects and Fluent Builder could help with it


How to best approach introducing the pattern in OpenLMIS?

  • Refactoring all the test classes at once / in a single ticket is probably not achievable
  • Do it as we go - instead of introducing a new test object in a private method - create a suitable builder per Fluent Builder pattern
  • Make sure we enforce that in code reviews - also update the code review checklist
  • Have a proof of concept - at least one implementation of the Fluent Builder pattern to have an example to follow


How about Fixture objects?

  • Not a big issue currently, since this is something that solves problems integrating multiple SUT Builders and Fluent Builders
  • Set up for the tests done in methods annotated @Before - common setup in base, abstract classes
  • Could be useful if we decide to introduce fluent builders and SUT builders
  • Could help by having a single place to set up for both unit and integration testing and possibly reuse some of the test objects

Wrap up

We have asked every participant to give a score on how useful this meeting was and how helpful this specific material was. The voting was anonymous and each participant could give a score from 1 (useless) to 10 (very useful).
The averages were:

How useful are those meetings:  8/10
How useful was this specific material? (Unit Testing - Test Utility Code):  6.75/10


Final thoughts

  • Let's make sure we follow up on watched materials and discuss introducing the patterns in OpenLMIS
  • It wasn't something that was quite new or surprising - but it's still something that we miss in OpenLMIS
  • All examples were based on C#

Action items

OpenLMIS: the global initiative for powerful LMIS software