Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG - Fastlane Unit Tests #173 #194

Merged
merged 6 commits into from
Oct 27, 2023
Merged

BUG - Fastlane Unit Tests #173 #194

merged 6 commits into from
Oct 27, 2023

Conversation

anupdsouza
Copy link
Contributor

@anupdsouza anupdsouza commented Oct 20, 2023

What it Does

How I Tested

  • Executed unit tests locally using fastlane, bundle exec fastlane unit_tests
  • Ran github workflow after pushing to branch

Notes

  • Removed build_for_testing config setting which was only building the code but not executing the tests. Ref fastlane docs..
  • Updated gemfile to install xcov gem for code coverage.
  • Added xcov action in fastfile to provide code coverage.
  • Minimum code coverage has not been specified yet as there aren't enough tests written. This can be updated later by adding minimum_coverage_percentage: 80.0 with an acceptable benchmark value to the xcov action in the fastfile.
  • Added .xcovignore file in fastlane folder. This can be used to exclude files we do not need to test or require coverage to be gathered for. I believe model/business logic files are more suited for testing. This can be updated as development progresses.
  • Added xcodebuild_formatter config in fastlane to use xcbeautify for cleaner logs.
  • Updated github workflow to install dependencies via bundle (for gems) & via homebrew (for xcbeautify)
  • Right now the plan only executes unit tests via the only_testing config flag in fastlane. If removed, it will also execute UI tests ( GitHub Actions for Running UI Tests #54 ) but I've observed the workflow taking over an hour to complete on GitHub. So maybe it's something we need to weigh the pros & cons for?
  • Updated workflow such that only the last initiated workflow executes in order to prevent multiple workflows from running on multiple code push actions. See concurrency in workflow file.
  • In order to run locally, make sure to first run bundle update for installing gem dependencies and then run brew install xcbeautify to install xcbeautify for cleaner logging. You might need to use sudo incase you run into errors for write permissions to the ruby directory

Screenshots ~ Local

Screenshot 2023-10-20 at 5 26 24 PM Screenshot 2023-10-20 at 5 26 48 PM Screenshot 2023-10-20 at 5 27 48 PM

Coverage report ~ fastlane/CodeCoverageReport/index.html

Screenshot 2023-10-20 at 5 28 18 PM

Screenshots ~ Github workflow


Failing tests

Screenshot 2023-10-20 at 10 03 20 AM Screenshot 2023-10-20 at 10 03 31 AM

Passing tests

Screenshot 2023-10-20 at 9 48 38 AM Screenshot 2023-10-20 at 1 06 11 PM

Miscellaneous

  • We can add a unit test status badge to the ReadMe as well to provide a quick status of the unit testing workflow. It'd look something like this Unit Tests Workflow Badge but it would say passing or failing depending on the unit test workflow status. If you feel this adds value, please feel free to create an enhancement or improvement & assign to me & I'd be happy to take it up!

Removed build_for_testing config setting
Added xcov action for code coverage & excluded view files
Update gemfile with xcov gem
Update workflow to install dependencies
@mikaelacaron
Copy link
Owner

Thanks for the detailed PR!!

Right now the plan only executes unit tests via the only_testing config flag in fastlane. If removed, it will also execute UI tests ( #54 ) but I've observed the workflow taking over an hour to complete on GitHub. So maybe it's something we need to weigh the pros & cons for?

Yeah that's definitely an issue, let's not run them at this moment, and I may just run them manually for now (when it's needed)

We can add a unit test status badge to the ReadMe as well to provide a quick status of the unit testing workflow. It'd look something like this Unit Tests Workflow Badge but it would say passing or failing depending on the unit test workflow status. If you feel this adds value, please feel free to create an enhancement or improvement & assign to me & I'd be happy to take it up!

Yes I'll do this after I merge your PR!

I'll look at this soon, I haven't gone through the code changes, and I need to run it all locally still

Copy link
Owner

@mikaelacaron mikaelacaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minimum code coverage has not been specified yet as there aren't enough tests written. This can be updated later by adding minimum_coverage_percentage: 80.0 with an acceptable benchmark value to the xcov action in the fastfile.

Can you add this in the right spot, but comment it out?

I have a few questions too, noted below

I haven't been able to run this locally, bundle update has been timing out

fastlane/Fastfile Outdated Show resolved Hide resolved
fastlane/Fastfile Show resolved Hide resolved
Put back default fastfile template
Add & comment out minimum_coverage_percentage flag
Copy link
Owner

@mikaelacaron mikaelacaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!! I got it to run locally! Not sure what happened the first time

Thanks for your patience!

@mikaelacaron mikaelacaron merged commit 9049973 into mikaelacaron:dev Oct 27, 2023
2 checks passed
@anupdsouza anupdsouza deleted the dev-fastlane-configuration branch October 29, 2023 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG - Fastlane Unit Tests
2 participants