Skip to content

Types of assertions

Devrath edited this page Oct 24, 2023 · 1 revision

github-header-image

Observations

  • Assertions are usually used to test a function to check if what we are testing is working as expected

Types of assertions

Verifying the output of a function

  • We run a specific function with specific parameters and we check the result of the function.
  • We later perform an assertion on that particular output.
  • These tests are easy to write and maintain because even if the implementation changes still the test need not have to change

Verifying the state of the system

  • Here we run some actions and functions that change the state of the system.
  • The system can be an entire app, a specific class in an app, etc.
  • In Android context, We can call it a view model -> Say we run some functions of the View model and see if the UI state is properly manipulated
  • Verifying the correct values into DB. Say inserting the values in DB and checking if the state is successful in the view model.
  • These tests are easy to write but a bit hard to maintain.

Verifying the Communication

  • This is verifying that certain communication has happened between the classes.
  • We verify that a particular function was called, we don't check the end result.
  • These tests are hard to maintain.