Chizpon's avatar

Would this be a feature test, or a unit test?

Hi!

In the Laravel 6 from scratch, a user can follow another user, has followers and can see who follows him.

It's written in the user model (although extracted to a followable), so it can be accessed like auth()->user()->following

If i wanted to test that, would it be a unit test (UserTest.php)? or would it be a feature test (something like FollowableTest, or FollowTest)?

Thanks in advance!

0 likes
2 replies
bobbybouwmann's avatar

I would probably make this a feature test because you need multiple assets here. A user needs to be logged in before you can actually test your feature.

1 like
martinbean's avatar
Level 80

@chizpon A feature test tests, well, a feature. A unit test test how a feature is built, so mainly individual functions and what they return when you give them particular parameters.

If you need the framework, a database, or other outside resource, then it’s no longer a unit test.

1 like

Please or to participate in this conversation.