So you are in position to use some programming language in order to automate test. Welcome to the rabbit hole of software testing! If you would like to know more about software development in software testing, start with this excellent blog from Michael Bolton.
Now that you know difference between checking and testing, I will give an rspec example of proper automated check in REST API test.
In my example, REST API response is in JSON format. In case of successful response, message is:

{response = ‘success’}

and in case of some error, response message is:

{response=’error’, error=’error message’}.

How should we code in rspec response message check when we expect successful response?
First option:

response_message[‘response’].should eq(‘success’)

What is wrong with this check? What if we receive error message? Failure in that case would be:

expected response_message[‘success’] to be ‘success’ but ‘error’ received.

Do you know from test fail message what caused error?
Automated test has to be designed in following manner:

  • you are able to determine cause of fail directly from fail message
  • test has to be designed so that checks one and only one thing
  • test is independent from other tests. In rspec world that means it always produce same result when we use rspec option –order=random
In this example, proper check is:

response_message[‘error’].should be_nil

because in case of test failure, message is:

expected response_message[‘error’] to be nil but received
“message that explains reason for failure”