brain-marks icon indicating copy to clipboard operation
brain-marks copied to clipboard

FEATURE: Add unit tests

Open aerickson14 opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe. At the moment there are no unit tests and parts of the app (Views and their @State variables) are hard to test.

Describe the solution you'd like Following https://www.swiftbysundell.com/articles/writing-testable-code-when-using-swiftui/ I'd like to do the following:

  • Refactor DataStoreManager into a protocol and have the current implementation conform to that protocol. This will set things up nicely to add a mock DataStoreManager so that it can the mock can be used when testing ViewModels that have DataStoreManager as a dependency
  • Start with CategoryList and move all of the @State variables into the CategoryListViewModel
  • Write tests for all public functions in CategoryListViewModel
  • Turn on code coverage to verify as much of the view model is tested as possible

Describe alternatives you've considered Writing unit tests for the Views directly would be a difficult approach

Additional context Add any other context or screenshots about the feature request here.

aerickson14 avatar May 15 '22 03:05 aerickson14

@aerickson14 This looks great! If you want to work on this, let me know and I'll assign it to you! I don't think we need to test the Views, just the ViewModels

mikaelacaron avatar May 15 '22 03:05 mikaelacaron