Suggestion: follow the "Arrange Act Assert" style for tests
See original GitHub issueCurrently our tests follow the clumsy Four-Phase Test style to describe the test body. I don’t like that at all, as it looks like some old-school stuff which doesn’t play nice with xUnit. My concerns:
- The
// Teardown
phase is always empty in xUnit tests as it creates asut
per test, without need torestore
it. - The
// Fixture setup
,// Exercise System
and// Verify Outcome
looks too verbose, while// arrange
,// act
and// assert
are more laconic. If you don’t create test from a template, it’s much simpler to write those words (it’s always hard to writeexercise
without typos 😅).
Therefore, @moodmosaic if you don’t have any strong objections (I hope you don’t), I would like to switch us to 3 phase tests and use it all our the tests. It will allow me to feel satisfaction during the test creation, rather than pain 😖
Issue Analytics
- State:
- Created 6 years ago
- Comments:22 (22 by maintainers)
Top Results From Across the Web
Arrange-Act-Assert: A Pattern for Writing Good Tests
Arrange -Act-Assert is a great way to structure functional test cases. It forces tests to focus on independent, individual behaviors.
Read more >The Arrange, Act, Assert (AAA) pattern ...
The Arrange, Act, Assert (AAA) pattern is a neat little strategy to help keep your test code cleaner and easier to read and...
Read more >Unit Testing and the Arrange, Act and Assert (AAA) Pattern
It suggests that you should divide your test method into three sections: arrange, act and assert. Each one of them only responsible for...
Read more >Are heading comments recommended when unit testing ...
When you need arrange, act, assert comments to make your test understandable you're basically saying "I haven't had time to clean this test...
Read more >Arrange Act Assert pattern for Python developers - James Cooke
This post introduces the Arrange Act Assert pattern of testing and shows how it can be used in a Python context with Pytest....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Usually I use
// Act & Assert
as it looks more concise and cool 😎 Unless @moodmosaic has concerns, I’d prefer to follow that style 😉Great that it worked! 👍
I’d suggest to look at this article, the workflow is well described there: https://github.com/sevntu-checkstyle/sevntu.checkstyle/wiki/Development-workflow-with-Git:-Fork,-Branching,-Commits,-and-Pull-Request
Basically, you don’t need to associate a branch with this issue. Rather, you create a Pull Request and simply mention this issue in the body (e.g. see this one).