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

Extract building logic to EventsBuilder. Add unit tests for it. #79

Merged
merged 18 commits into from
Oct 20, 2023

Conversation

wzieba
Copy link
Collaborator

@wzieba wzieba commented Oct 17, 2023

Description

This PR extracts logic of building events (pixels) and covers it with unit tests. It doesn't introduce any change in terms of how SDK works.

Tests

No need - review and CI check should be enough.

@codecov
Copy link

codecov bot commented Oct 17, 2023

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (e33285b) 0.00% compared to head (5394212) 20.44%.

Additional details and impacted files
@@            Coverage Diff             @@
##            main      #79       +/-   ##
==========================================
+ Coverage   0.00%   20.44%   +20.44%     
==========================================
  Files          4        5        +1     
  Lines        358      362        +4     
  Branches      58       58               
==========================================
+ Hits           0       74       +74     
+ Misses       358      278       -80     
- Partials       0       10       +10     
Files Coverage Δ
...ava/com/parsely/parselyandroid/ParselyTracker.java 0.86% <0.00%> (+0.86%) ⬆️
...java/com/parsely/parselyandroid/EventsBuilder.java 89.39% <89.39%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wzieba wzieba marked this pull request as ready for review October 18, 2023 14:18
@wzieba wzieba requested a review from ParaskP7 October 18, 2023 14:19
@ParaskP7 ParaskP7 self-assigned this Oct 19, 2023
Copy link
Collaborator

@ParaskP7 ParaskP7 left a comment

Choose a reason for hiding this comment

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

👋 @wzieba !

I have reviewed and tested this PR as per the instructions, everything works as expected, awesome job adding our first unit test! 🌟 🎉 🌟


Comparison is base (e33285b) 0.00% compared to head (d202510) 20.44%.

🎉 🌟 🎉


I have left a question (❓), a couple of suggestions (💡) and some minor (🔍) comments for you to consider. I am going to approve this PR anyway, since none is blocking. I am NOT going to merge this PR yet to give you some time to apply any of my suggestions. However, feel free to ignore them and merge the PR yourself.

codecov.yml Show resolved Hide resolved
}

@Test
fun `events builder prepares correct pageview pixel`() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

DISCLAIMER: This is discussion territory, please take it with a grain of salt since all that is just personal test style, nothing more, nothing less.

  1. Suggestion (💡): How about always using the given ..., then ..., when ... pattern for every test description? Actually, I am seeing you already using that patter on a few tests further below, so I am not sure when and why you are choosing one over the other. I would personally prefer such a consistency across every test so I don't have to think when to use which patter. Wdyt? 🤔
  2. Minor (🔍): When using the given ..., then ..., when ... pattern, I suggest only the given part be optional, but the when and then to be always present. For example, for all of your given ..., then ..., when ... related test below, I notice you are not including the then, why is that? 🤔
  3. Minor (🔍): Consider removing the // given, // when and // then comments. IMHO, as long as you split the given/when with an empty line (when there is a given), and then the when/then with another empty line, this is already enough. Otherwise, you get an extra 2/3 lines of code per test, which I debate it being unnecessarily.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! I've updated the names of tests, but decided to leave comments. For some reason, they make the test much more readable for me, the space feels easy to misplace by accident. I'll keep thinking about this though :)

I notice you are not including the then, why is that?

Did you mean name of tests? Because every test contain the then part - or am I missing something?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks! I've updated the names of tests, but decided to leave comments. For some reason, they make the test much more readable for me, the space feels easy to misplace by accident.

Yes, I understand this @wzieba , it is indeed helping if you aren't used to just depend on line breaks.

I'll keep thinking about this though :)

🤔 🥇 😄

Did you mean name of tests? Because every test contain the then part - or am I missing something?

Me being... 🔍 🔍 🔍 😄

An example of such test is this one: given extraData is null, when creating a pixel, don't include extraData

Notice the then missing from the last sentence which starts with don't instead of then don't. 🤷

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Gotcha, so it was the name - updated 🙌

@wzieba wzieba merged commit 22a8241 into main Oct 20, 2023
3 checks passed
@wzieba wzieba deleted the eventbuilder_unit_tests branch October 20, 2023 09:59
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.

None yet

2 participants