Don’t use hard assertions everywhere!

Sajitha Pathirana
Webtips
Published in
4 min readDec 19, 2021

--

#Assertions #SoftAssertions #HardAssertions #Verifications

Assertions are the guide sticks in test automation. Hence the assertions play the most vital role in test automation to identify issues in the system under test. Adding more meaningful assertions will offer reliability in the functionality of the application.

Photo by mari lezhava on Unsplash

More assertions → more checkpoints → more functional validations.

Mainly there are two types of assertions.

  • Hard Assertions
  • Soft Assertions

Hard Assertions would validate the expected and actual values right on spot, causing the tests to fail on the spot if there are discrepancies.

Soft Assertions would validate all the assertions and if there are discrepancies, would fail after validating all the assertions.

Each has its own usages, advantages, and disadvantages. Here is my article on Hard Assertions.

--

--

Sajitha Pathirana
Webtips

A Test automation enthusiast, passionate to help the teams to enhance their testing journey with his decade of experience in the field.