Automation Learn

06 Assertions Reporting

Imagine you have hired a world-class security guard to watch over your house while you go on vacation. You give them keys, a uniform, and a checklist. You return two weeks later, and the guard smiles and says, “I walked around the house every day.”

You ask, “Did anyone try to break in?” The guard shrugs. “I walked around the house.” You ask, “Was the back door locked?” The guard smiles. “I walked around the house.”

This guard is useless. They performed the actions (walking), but they didn’t verify anything (checking locks, spotting intruders) and they didn’t report back to you effectively.

In software testing, clicking buttons and typing text is just “walking around the house.” Assertions are the moment the guard checks the lock. Reporting is the detailed logbook they hand you when you return. Without these two, your automation is just code taking a walk.

In this module, we are going to turn your scripts into Sherlock Holmes—observant, critical, and excellent at explaining exactly what happened at the scene of the crime.


6.1 Assertion Libraries: The Art of the Truth

If a test performs an action but doesn’t check the result, it is not a test; it is just a tour. Assertions are the checkpoints where your code stops and asks: “Is the reality of the application matching my expectation?”

6.1.1 The Two Philosophies: Hard vs. Soft Assertions

When a detective finds a clue that doesn’t fit, they have two choices. They can immediately stop the investigation and scream “MURDER!” (Hard Assertion), or they can take a note in their notebook, continue looking for more clues to build a full picture, and then present the findings (Soft Assertion).

6.1.2 Matchers: From Simple Math to DNA Matching

Assertions are not just about A == B. Sometimes we need to check if a suspect looks like the perpetrator, or if they were in the crowd.


6.2 Evidence Collection: The Crime Scene Photographer

You are sleeping. Your automated tests run at 3:00 AM. One fails. You wake up at 9:00 AM and see a red “X” on your dashboard.

Without evidence, you have to guess what happened. Did the page not load? Did the button move? Was there a popup covering the button? You are now a detective arriving at a crime scene that has already been cleaned up.

We need to freeze the crime scene in time.

6.2.1 Taking Screenshots on Failure (The Polaroid Moment)

A picture is worth a thousand log lines. When a test fails, the browser is looking at the error. We need to snap a photo right before the browser closes.

6.2.2 Logs and Network Dumps (The Wiretap)

A screenshot shows you what the user saw (the UI). But it doesn’t show you what the application felt (the internal logic).


6.3 Reporting Frameworks: The Storyteller

You have run 500 tests. 495 passed. 5 failed. If you send your manager a text file with 5,000 lines of console output saying System.out.println("Test passed"), they will fire you. Or at least, they will ignore you.

Stakeholders (Managers, Developers, PMs) do not speak “Code.” They speak “Charts,” “Trends,” and “summaries.” Your report is the translation layer between your technical brilliance and their business decisions.

6.3.1 Configuring Rich Reports (The Dashboard)

We are moving away from plain text logs to HTML dashboards. Tools like Allure, Extent Reports, or the HTML Publisher in Jenkins/CI tools transform dry data into a visual story.

6.3.2 Reading the “Stack Trace” (The Autopsy)

The Stack Trace is the most intimidating and most useful part of a failure. It is the autopsy report. It tells you exactly where the code died.

6.3.3 Tagging: The Filing Cabinet

As your suite grows to 1,000 tests, you will rarely run all of them at once locally. You need a way to filter.


Summary: The “Definition of Done”

By the end of this module, you won’t just be writing scripts that click things. You will be architecting a Quality Safety Net.

  1. Your Assertions will catch bugs with precision, using Soft Assertions to gather full context and Hard Assertions to stop catastrophic failures.
  2. Your Evidence will be automatic. No more “I can’t reproduce it on my machine.” You will have a screenshot and a log for every crime scene.
  3. Your Reporting will be beautiful, categorized, and readable by humans, not just robots.

When you hand over your test report, you are handing over confidence. You are saying, “I have checked the locks, I have walked the perimeter, and here is the photo of the open window I found.”

Let’s get coding.

← Back to Modules