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

June's blog post: Arrange Act Assert guide #10

Merged
merged 8 commits into from
Jul 6, 2017
Merged

June's blog post: Arrange Act Assert guide #10

merged 8 commits into from
Jul 6, 2017

Conversation

jamescooke
Copy link
Owner

Late, but 90% of the way there. Needs proof reading.

All suggestions welcome 😄

@jamescooke
Copy link
Owner Author

TODO:

  • Set as published.
  • Add subscription info.

@@ -13,7 +13,7 @@ At `PyConUK 2016
<http://2016.pyconuk.org/talks/cleaner-unit-testing-with-the-arrange-act-assert-pattern/>`_
I spoke about the Arrange Act Assert pattern and how it can help clean up unit
tests. I plan to write a short guide to AAA for Python developers and will
link to that from here when done - meanwhile, below are my slides and links
link to that from here when done - meanwhile, below is the video of the talk, my slides and links
Copy link
Contributor

Choose a reason for hiding this comment

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

oxford comma? 😉

Copy link
Owner Author

Choose a reason for hiding this comment

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

This bad phrase will be removed when I link to the guide now.

@@ -74,5 +81,4 @@ Finally
-------

Thanks again to `Carles <https://github.com/txels>`_ for introducing me to the
AAA pattern. Check out his `data driven tests library
<https://github.com/txels/ddt>`_.
Copy link
Contributor

Choose a reason for hiding this comment

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

OOI, why remove the ref to ddt? Found other solutions like pytest.mark.parametrize 😉?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes exactly that 😊

:status: draft

This is the first post in a series exploring the Arrange Act Assert pattern and
how to apply it to Python unit tests.
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe scrap the word 'unit'? It can be applied to functional tests too, etc.


I'll now go into detail on each of these parts using Pytest and a simple toy
test example. We'll write a simple happy-path test for Python's builtin
``list.reverse`` function.
Copy link
Contributor

Choose a reason for hiding this comment

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

You're mixing "I'll" / "We'll" in this paragraph, which sounds a bit confused

* We all love `PEP008 <https://www.python.org/dev/peps/pep-0008/>`_, so we want
tests to pass ``flake8`` linting.

* `PEP020 <https://www.python.org/dev/peps/pep-0020/>`_ is also something we
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this as the 'zen of python' instead of PEP 20, I had to click the link to remind myself that's what it is - maybe mention it as:

PEP020, The Zen of Python, is also something...

Docstring
---------

A short single line statement about the behaviour under test.
Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I feel good test method names can make docstrings redundant in simple tests, and developers also find writing english harder than code 😉

Copy link
Owner Author

Choose a reason for hiding this comment

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

That's a helpful point. I've realised while considering this that the docstring is not really part of the pattern - it's my own addition. I'll rephrase to indicate that.

will explore strategies for extracting common assertion code and testing it
in its own right.

Links will appear above when I complete these follow up posts.
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking forward! 👀

Copy link
Owner Author

Choose a reason for hiding this comment

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

Me too! I hope that I can keep up with the one post per month schedule! 😅

@jamescooke
Copy link
Owner Author

Thanks for the revew @adamchainz ... merging and publishing now.

@jamescooke jamescooke merged commit 6ecc217 into master Jul 6, 2017
@jamescooke jamescooke deleted the aaa-guide branch July 6, 2017 22:07
Background
----------

I'll now go into detail on each of these parts using Pytest and a toy
Copy link

Choose a reason for hiding this comment

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

Do you mean toy here or tox? Just checking.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I definitely mean "toy". This is just a toy example where I write a test for something in stdlib.

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