Comments (6)
I prefer the first π¬
from php-ddd-example.
@xabi93 was just asking to me how to implement integration test in his PR: #29
One of the doubts was regarding the confusing folder structure, so maybe he's interested into this issue :P
Maybe we could define a test structure based on the one we've used for the https://github.com/CodelyTV/scala-http-api/ project:
$ tree scala-http-api/src/test/tv/codely/scala_http_api/module -L 5
.
βββ IntegrationTestCase.scala
βββ UnitTestCase.scala
βββ shared
βΒ Β βββ domain <- Test infrastructure such as the application domain model stubs/object mother
βΒ Β βΒ Β βββ DateTimeStub.scala
βΒ Β βΒ Β βββ DurationStub.scala
βΒ Β βΒ Β βββ IntStub.scala
βΒ Β βΒ Β βββ StringStub.scala
βΒ Β βΒ Β βββ UuidStub.scala
βΒ Β βββ infrastructure <- Mix of test infrastructure and actual integration test for the infrastructure application layer implementations
βΒ Β βββ MessagePublisherMock.scala
βΒ Β βββ logger
βΒ Β βΒ Β βββ scala_logging
βΒ Β βΒ Β βββ ScalaLoggingLoggerShould.scala <- ScalaLoggingLogger class integration test
βΒ Β βββ message_broker
βΒ Β βββ rabbitmq
βΒ Β βββ MessageConsumer.scala <- Infrastructure needed for the integration test
βΒ Β βββ MessagePurger.scala <- Infrastructure needed for the integration test
βΒ Β βββ RabbitMqMessageConsumer.scala <- Infrastructure needed for the integration test
βΒ Β βββ RabbitMqMessagePublisherShould.scala <- RabbitMqMessagePublisher class integration test
βΒ Β βββ RabbitMqMessagePurger.scala <- Infrastructure needed for the integration test
βββ video
βββ VideoIntegrationTestCase.scala
βββ application
βΒ Β βββ create
βΒ Β βΒ Β βββ VideoCreatorShould.scala <- Use case unit test
βΒ Β βββ search
βΒ Β βββ VideosSearcherShould.scala <- Use case unit test
βββ domain <- Test infrastructure such as the application domain model stubs/object mother
βΒ Β βββ SeqStub.scala
βΒ Β βββ VideoCategoryStub.scala
βΒ Β βββ VideoCreatedStub.scala
βΒ Β βββ VideoDurationStub.scala
βΒ Β βββ VideoIdStub.scala
βΒ Β βββ VideoStub.scala
βΒ Β βββ VideoTitleStub.scala
βββ infrastructure <- Mix of test infrastructure and actual integration test for the infrastructure application layer implementations
βββ marshaller
βΒ Β βββ VideoJsValueMarshaller.scala <- Test infrastructure needed in order to avoid using the production marshaller and actually testing its behaviour
βββ repository
βββ DoobieMySqlVideoRepositoryShould.scala <- DoobieMySqlVideoRepository class integration test
βββ VideoRepositoryMock.scala <- Test infrastructure needed in order to do not use production implementations in unit tests
However, I'm not 100% confident about it. So I'm not sure if we would have to replicate it in this project, or iterate it a little bit. Here you have an alternative I would take into account before refactoring:
$ tree scala-http-api/src/test/tv/codely/scala_http_api/module -L 5
.
βββ shared
βΒ Β βββ infrastructure
βΒ Β βΒ Β βββ IntegrationTestCase.scala
βΒ Β βΒ Β βββ UnitTestCase.scala
βΒ Β βΒ Β βββ message_broker
βΒ Β βΒ Β βΒ Β βββ MessagePublisherMock.scala
βΒ Β βΒ Β βΒ Β βββ rabbitmq
βΒ Β βΒ Β βΒ Β βββ MessageConsumer.scala
βΒ Β βΒ Β βΒ Β βββ MessagePurger.scala
βΒ Β βΒ Β βΒ Β βββ RabbitMqMessageConsumer.scala
βΒ Β βΒ Β βΒ Β βββ RabbitMqMessagePurger.scala
βΒ Β βΒ Β βββ stub
βΒ Β βΒ Β βββ DateTimeStub.scala
βΒ Β βΒ Β βββ DurationStub.scala
βΒ Β βΒ Β βββ IntStub.scala
βΒ Β βΒ Β βββ StringStub.scala
βΒ Β βΒ Β βββ UuidStub.scala
βΒ Β βββ integration
βΒ Β βββ logger
βΒ Β βΒ Β βββ ScalaLoggingLoggerShould.scala
βΒ Β βββ message_broker
βΒ Β βββ RabbitMqMessagePublisherShould.scala
βββ video
βββ infrastructure <- Only test infrastructure
βΒ Β βββ VideoIntegrationTestCase.scala
βΒ Β βββ marshaller
βΒ Β βΒ Β βββ VideoJsValueMarshaller.scala
βΒ Β βββ repository
βΒ Β βΒ Β βββ VideoRepositoryMock.scala
βΒ Β βββ stub <- Stubs/Object mother also understood as test infrastructure
βΒ Β βββ SeqStub.scala
βΒ Β βββ VideoCategoryStub.scala
βΒ Β βββ VideoCreatedStub.scala
βΒ Β βββ VideoDurationStub.scala
βΒ Β βββ VideoIdStub.scala
βΒ Β βββ VideoStub.scala
βΒ Β βββ VideoTitleStub.scala
βββ integration <- Only integration tests
βΒ Β βββ repository
βΒ Β βββ DoobieMySqlVideoRepositoryShould.scala
βββ unit <- Only unit tests
βββ VideoCreatorShould.scala
βββ VideosSearcherShould.scala
We've discussed sometimes about this, and I'm neither 100% sure about this second approach, however, there are some pros that I really like despite the cons:
Pros:
- We don't mix different kind of things in the
infrastructure
folders. Now we would be separating what we understand as classes only intended for testing (test infrastructure), and classes actually testing the behavior of the infrastructure layer in the production code (integration tests).
Cons:
- We do lose the previous similarities between the
src
folder structure and thetest
one. We can see this specially while taking a look at thestub
folder. Now we would be understanding that these classes belong to the tests infrastructure.
What do you think?
from php-ddd-example.
I don't have a really strong opinion here, soβ¦ go ahead with the first approach then π
from php-ddd-example.
π¬π¬π¬
from php-ddd-example.
I think having tests separately in another folder is cleaner, and making it easier to know where to add another test.
Now I have to add integration tests for the telegram notification and I don't know where I have to modify, but maybe this is my fault, not because of the project structure. π
from php-ddd-example.
Not at all @xabi93!
We're evaluating this change because the current tests structure is not clear enough. So it's completely understandable how it can frustrate anyone new to the project facing tasks as the one you're trying to do.
In the meantime, I had posted a comment in your PR (#29 (comment)) explaining how could you add this integration test in the current test structure. We'll move it with all the other test code when we take action on this issue, but this way you can continue with your PR without being blocked π
from php-ddd-example.
Related Issues (20)
- Error on make build HOT 5
- Modelos de Dominio con name creators
- Application services expose entities
- The flush method should be outside repositories
- We should not flush an entity
- Unable to create the "cache" directory HOT 3
- Finder application services has different behaviours. Why?
- Windows users HOT 1
- On make build in windows "installed make using choco" HOT 1
- Errror make build new version symfony HOT 2
- Elasticsearch + criteria pattern
- Autenticar usuario implementa Command en lugar de Query
- Database transaction boundary HOT 2
- json_encode() y json_decode() puede lanzar exception desde PHP 7.3
- Deptrac support HOT 1
- Incongruencias entre readme y makefile
- [CONSULTA] Relacion Video y Course
- ΒΏPor quΓ© `CourseRenamer` instancia el Servicio de AplicaciΓ³n `CourseFinder` en lugar de un Servicio de Dominio?
- Problema al ejecutar el `make build` HOT 1
- What buisness logic does Utils.php provides?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-ddd-example.