7

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
  • 143
  • 2
  • 12

1 Answers1

15

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
  • 166
  • 1
  • 2
  • 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
  • as @MladenJanjetovic said, I experienced that feature test is something in development mode, but the end-to-end test is some production team or test team stuff. When you are talking about API, it is something between machines and is faceless. but let's take another example that I heard in laracasts movies that makes all sense. Suppose you have a form, and this form will send a post request to the backend to do something like inserting to DB. your feature test will make a post request and checks the DB. not filling the form, which is an end-to-end test. – Armin.G Apr 16 '22 at 18:14