lundi 30 novembre 2020

Laravel (or not) Feature vs Unit Tests

In laravel or none laravel application we have tests like Feature and Unit tests (or whatever, browser, integration they are the same things in different languages as i understood). I read from different places and some of them says that "do not use database operations in your unit tests" and other article gives an example with product creation on unit tests, so i am confused about it and i really want to do it the right way.

For now i just wrote all of my tests as feature tests but i want to separate them my structure is like:

 - Feature
    - Admin
    - Auth
    - Dev (routes that only developers can access)

Until now i had written tests that check CRUD operations and CRUD operations without needed permission (403, no permission returned) and some validation tests like required and valid email, and also login with correct and incorrect credentials.

Which of those should i write as a unit test and also when i separated them should i have the same directory structure as feature tests? Like this:

 - Feature
    - Admin
    - Auth
    - Dev (routes that only developers can access)

- Unit
    - Admin
    - Auth
    - Dev (routes that only developers can access)

Aucun commentaire:

Enregistrer un commentaire