How to write a good test message
This article draws inspiration from Chriss Beams' blog post on writing right commit messages. There is no consensus on how to write a test message, but there is certainly plenty of conventions around test message. At the end of the day, test messages get written according to developers' taste at a given time — this article entices curiosity around choosing the right test message format.
Like other posts that came before this blog, we will take a different turn, and focus on asking basic questions, as opposed to prescribing some magic solution to the issue.
If you haven't already, read the “How to write Test Cases developers will love”. The key difference between these two blog posts is that this blog focuses more on the semantics of a message. The other, blog focuses on the adoption of a template or school of thought when it comes to test cases.
This blog tries to present elements that can improve the messaging when writing a test case.
In this article we will talk about:
- Definition of a message in a testing context
- Difference between BDD and TDD test scenario message
- Choosing the right test messages based on acceptance criteria
- Choosing the right regression test message
- Choosing the right message for testing class methods
- Choosing the right messages for solo functions
- Elements of a good testing message ~ How to spot a well-written message
- The wrong way to write a message ~ How to spot a bad-written message
- Example of state of the art test messages
- Writing message that validates User Story/JTBD ~ integration/e2e/system tests
Even though this blog post was designed to offer complementary materials to those who bought my Testing
nodejs
Applications book, the content can help any software developer to tuneup working environment. You use this link to buy the book.
What to expect from test cases
When writing test messages blueprint, we will have to answer thoroughly following questions in plain English. Our final product has is a mold most of our test messages have to fit in.
To start this exercise, let's take our typical test case message, and verify if it satisfies the questions below.
- Gather a sample of some good test messages from open source projects
- Write down some test messaging you find commendable
- Which one qualify as a state of the art test messages
- What can be considered Elements of a good test message
- How to spot a well-written message
- What should be a definition of a message in a testing context
- What is the difference between BDD and TDD message style, if any
- What should be considered the right messaging for regression test cases
- What can be seen as the right message for testing class methods
- What can be seen as the right for solo functions
- What can be considered the wrong way to write a message
- How to spot bad written message
- How to write a test message that validates User Story
- How to write a test message that validates Job Story
Answers to these kinds of questions provide a baseline to create a blueprint of test messages developers and businesses will love reading.
Conclusion
In this article, we revisited how to write test messages that convey clear information about what is being tested. There are additional complimentary materials in the “Testing nodejs
applications” book.
References
- Testing
nodejs
Applications book - How to write a good unit test message ~ StackOverflow Question, What are unit tests, integration tests, smoke tests, and regression tests? ~ StackOverflow Question, Assert Message in Unit Tests ~ Software Engineering StackExchange
- AngularJS migration — beef up your test cases ~ Hoogy Medium Publication
- Bug Report Template ~ Marker Blog
- Bug and Issue Tracker ~ AirTable blog