A
A
Arthur2019-05-15 19:46:51
Unit testing
Arthur, 2019-05-15 19:46:51

Where is the truth in unit tests?

Good afternoon, I read a lot about unit tests and I constantly see two different approaches.
First approach.

$response = $test->create($data);
$this->assertInstanceOf(Test::class, $response);

Second approach.
$response = $test->create($data);
$this->assertEquals($response->test, $data['test']);
$this->assertEquals($response->test1, $data['test1']);

Supporters of the first approach argue that unit tests do not care what kind of data came in and only the structure is important to them, and functional tests should be responsible for data validation.
Supporters of the second approach argue that their tests do not have external dependencies and they are right.
What approach are you using?
I would be glad to hear your arguments.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question