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

gh_322: Improve test structure #323

Merged
merged 2 commits into from
Jun 19, 2021

Conversation

rodinant
Copy link
Contributor

No description provided.

Copy link
Owner

@yashaka yashaka left a comment

Choose a reason for hiding this comment

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

please refactor according to comments

@@ -38,34 +38,37 @@ def test_search_is_postponed_until_actual_action_like_questioning_count(
):
page = GivenPage(session_browser.driver)
page.opened_empty()

elements = session_browser.element('ul').all('.will-appear')
Copy link
Owner

Choose a reason for hiding this comment

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

moving this line further is wrong, because the main idea of this test, is to show, that search of actual element will not appear before loading actual body with .will-appear elements...

page.load_body(
'''
<ul>Hello to:
<li class='will-appear'>Bob</li>
<li class='will-appear'>Kate</li>
</ul>'''
)
elements = session_browser.element('ul').all('.will-appear')

length = len(elements)
Copy link
Owner

Choose a reason for hiding this comment

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

the test name already uses word "count" for this context...
that's why it would be more consistent and readable to name this variable as count too;)



def test_search_is_updated_on_next_actual_action_like_questioning_count(
session_browser,
):
page = GivenPage(session_browser.driver)
page.opened_empty()
elements = session_browser.element('ul').all('.will-appear')
Copy link
Owner

Choose a reason for hiding this comment

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

here, it's not like that important to keep this line here, because we nevertheless will ask for count twice, and only second time is a part of our test goal...
yet... also no much reason to move further...
would be simpler to keep this line here for kind of consistency with previous test structure...


length = len(elements)

assert length == 2
Copy link
Owner

Choose a reason for hiding this comment

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

here we don't need an assert actually (because yet this is a precondition...)... we just need to store the current length (that should be better named as count)

we can, by the way, have asserts in preconditions for some reason... if catching some extra errors would be more optimal as early as possible... but at least - not obligatory... and maybe if moving this asserts to the end of test - would make test logic cleaner... and this assert in precondition would not distract us...

@@ -76,14 +79,14 @@ def test_search_is_updated_on_next_actual_action_like_questioning_count(
</ul>'''
)

assert len(elements) == 3
new_length = len(elements)
Copy link
Owner

Choose a reason for hiding this comment

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

again, better to name as updated_count not new_... because the word "updated" is already used in test name

assert len(elements) == 3
new_length = len(elements)

assert new_length == 3
Copy link
Owner

Choose a reason for hiding this comment

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

can be tuned to something like assert 3 == updated_count != first_count
or
assert updated_count == 3
assert updated_count != first_count

@@ -92,5 +95,8 @@ def test_searches_exactly_inside_parent(session_browser):
</ul>
<li class='forgotten'>Joe</li>'''
)
elements = session_browser.element('ul').all('.will-appear')

length = len(elements)
Copy link
Owner

Choose a reason for hiding this comment

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

better to use count word for consistency with previous tests



def test_searches_exactly_inside_parent(session_browser):
page = GivenPage(session_browser.driver)
page.opened_empty()

elements = session_browser.element('ul').all('.will-appear')
Copy link
Owner

Choose a reason for hiding this comment

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

same as above... this line should be here (not moved further)

@@ -38,34 +38,37 @@ def test_search_is_postponed_until_actual_action_like_questioning_count(
):
page = GivenPage(session_browser.driver)
page.opened_empty()

elements = session_browser.element('ul').all('.will-appear')
page.load_body(
'''
<ul>Hello to:
<li class='will-appear'>Bob</li>
<li class='will-appear'>Kate</li>
</ul>'''
Copy link
Owner

Choose a reason for hiding this comment

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

let's move last ''' to next line here, and below when needed... ;)

@rodinant rodinant force-pushed the issue_322_improve_test_structure branch from 332664d to eeb3e72 Compare June 15, 2021 15:53
@codecov-commenter
Copy link

Codecov Report

Merging #323 (eeb3e72) into master (1e0fced) will decrease coverage by 0.10%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #323      +/-   ##
==========================================
- Coverage   61.18%   61.07%   -0.11%     
==========================================
  Files          35       35              
  Lines        1829     1829              
  Branches      117      117              
==========================================
- Hits         1119     1117       -2     
- Misses        682      684       +2     
  Partials       28       28              
Flag Coverage Δ
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
selene/core/wait.py 92.59% <0.00%> (-3.71%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e0fced...eeb3e72. Read the comment docs.

@yashaka yashaka merged commit 265cc3d into yashaka:master Jun 19, 2021
github-actions bot added a commit that referenced this pull request Jun 19, 2021
fix #322: Merge pull request #323 from rodinant/issue_322_improve_test_structure
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.

3 participants