Unit testing
- Unit tests: A single piece of code (usually an object or a function) is tested, isolated from other pieces
- Integration tests: Multiple pieces are tested together, for example testing database access code against a test database
- Acceptance tests (also called Functional tests): Automatic testing of the entire application
Unit tests. These tests ensure that individual components of the application work as expected. Assertions test the component API.
Integration tests. These tests ensure that component interactions work as expected against external artifacts like databases. Assertions can test component API, UI, or the side effects of actions like database I/O, logging, etc.
Functional tests for each microservice. These tests ensure that the application works as expected from the user's perspective.
Service tests. These tests ensure that end-to-end service use cases, including testing multiple services at the same time, are tested. For this type of testing, you need to prepare the environment first. In this case, it means starting the services (for example, by using docker-compose up).
TDD
- First the developer writes some tests.
- The developer then runs those tests and (obviously) they fail because none of those features are actually implemented.
- Next the developer actually implements those tests in code.
- If the developer writes their code well, then the in next stage they will see that their tests pass.
- The developer can then refactor their code, add comments and clean it up, as they wish because the developer knows that if the new code breaks something, then the tests will be an alert by failing.
BDD
DDD
- Development becomes domain oriented not UI/Database oriented
- Domain layer captures all of the business logic, making your service layer very thin i.e. just a gateway in to your domain via DTO's
- Domain oriented development allows you to implement true service-oriented architecture i.e. making your services reusable as they are not UI/Presentation layer specific
- Unit tests are easy to write as code scales horizontally and not vertically, making your methods thin and easily testable
- DDD is a set of Patterns and Principles, this gives developers a framework to work with, allowing everyone in the development team to head in the same direction
No comments:
Post a Comment