Answer the question
In order to leave comments, you need to log in
What is the difference between e2e and unit tests?
Hey! I'm trying to test an agular application using protractor
and е2е
testing. After reading a lot of articles on the Internet, the question arose - what is the difference between unit and e2e tests? In general, I understood the difference from the articles, the question is not so much about the methodology as about the structure and organization of these tests. In what directories should they be stored? What does the project tree look like with e2e and unit tests? As I understand it е2е
, everything is *.spec.ts
added *.po.ts
to a separate folder at the src
. In unit
tests, everything *spec.ts
lies directly with *.component.ts
. Right? Can е2е
tests be in the folder with the components they are testing? In short, a drug addict question all day I read everything I see.
Answer the question
In order to leave comments, you need to log in
unit test - test of one
e2e module - end to end - test with the given framework , the
units usually lie next to the modules themselves (in golang, for example, client.go and client_test.go are nearby - this is normal),
and e2e are placed in a separate test folder in which, in addition to these e2e all sorts of helpers and clients to support services)
and units are launched before assembly, and e2e after it
Well, technically they can, who will forbid you.
But here it is necessary to make a distinction no longer technological, but business.
units - a lot of them are launched before building / rolling out the application, since they are locked, they pass quickly and are stable, well, they are more technical than business
e2e - this is already more about business cases. There should be few of them. They are tied to third-party services, are not locked and therefore not stable. and launch them already as part of a larger regression. And it’s logical to keep them somewhere in one place, so that when they again have to be repaired and corrected, you don’t have to look for them where the hell.
Unit tests (aka unit tests).
Frameworks: Jest, Jasmine/Karma.
They lie in the same folder next to the file being tested and have the .spec suffix.
They test one specific module, a module can be understood as a specific function or class, in general they test one thing and serve as excellent documentation that is always up to date. For better code coverage and improvement, we use the TDD technique (red, green, refactor), first we write tests, then the code so that these tests pass and refactor, then the process is repeated. They are usually written more frequently than e2e tests and are cheaper in the sense that they are smaller in terms of code size and easier to write.
E2E tests.
Frameworks: Cypress, Protractor.
They test part of the application and their relationship (there are many nuances here), in general, they have a larger coverage area and they test exactly the behavior of the application, simulating user actions. Created as a separate project.
Generally something like this, IMHO.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question