5

I am currently developing a Project using Laravel5.7 and now am doing testing part. I have written code for unit testing in tests/unit directory. Next thing I see is a test/Feature directory. So my question is whether feature testing and integration testing are the same or do they have any difference.

Any help is appreciated

Harinath R
  • 83
  • 10

1 Answers1

9

by definition feature and integration testing are not necessarily the same.

Unit tests usually test the smallest unit in your code which is most likely a method or function. Integration tests should make sure that more than one unit or one or more modules work together as expected. A feature test is usually an end to end test, e.g. you test an API endpoint via HTTP request and assert its response. The API request will go through all layers of your application, for instance controller, models, DBAL, DBMS.

We run quite a big, multi-tenanted Laravel application in my company and we have the following test suites: * Unit tests * Http tests for API endpoints (end to end, without DB mocks) * Browser tests w/ Dusk (end to end, without DB mocks)

All external / 3rd party calls (i.e. Facebook API, email service provider) are mocked in the tests.

user1720258
  • 106
  • 1
  • If you are testing API than yes feature test is like end to end test. But in other scenarios feature test can be only the part of the bigger end to end path of the user. At least it's my understanding, because I didn't find like universal definitions of test types in software development. It can vary. – Mladen Janjetovic Jun 18 '19 at 12:26