Asserting API Response
Automation tests are only validating if they assert the expected results. Asserts are used to verify the expected results from the endpoint.
Status Code Asserts:
Example:
/**
* Test that the route /user/mobilenumber returns 200
*
* 'number' => 'required|min:10|max:10',
*
* @test
* @return void
*/
public function user_put_method_mobile_number_returns_200(): void
{
$this->actingAsAdmin()
->authenticate()
->put('/user/mobilenumber', [
"number" => "1555".rand(100000,999999)
])
->assertOk();
}JSON Response Asserts:
Interacted
What and what not to assert
Incomplete Tests
Last updated