Hi folks! I don't know if this is the best channel...
# getting-started
l
Hi folks! I don't know if this is the best channel to ask you this, be here we go: I have an application built with Spring Boot and Gradle, which connects with Kafka and PostgreSQL. I'm using
resources/application.yml
as the config file. I want to create a specific package for each of this kinds of tests: unit, integration and end-to-end, but now I have a package only for unit tests. The problem is: every time I run the unit tests, my Spring Boot application try to connect with Kafka and Postgres (but for this purpose, I don't need them). How can I avoid to connect with these tools when running my unit tests? Also, do you know some blog post or documentation that shows how to create distinct packages for each kind of tests? Thanks in advance 🙂
k
Anything related to Kotlin in here?
🚫 1
l
The project was built with Kotlin, but since I'm kind of new to this Slack I don't know where I can ask this question. Do you know, @Kirill Grouchnikov? Or do you know some blog post that can help me with that? Thanks!!
h
Your question is about Spring Boot, not about Kotlin. That's why this Slack is not really the right place for the question. How about asking on Stackoverflow instead?
☝️ 1
l
My bad 😅 thanks, @hho!
s
If you do run into the cross section of spring and kotlin in the future though, there is #spring
❤️ 1
f
@*Lucas Marques* the idiomatic spring approach to you problem is to have multiple layers (controller, service, repository) and when you unit test e.g. the service the you mock the repository layer - hence to db / kafka connection anymore. To make it a kotlin answer: I recommend mockk for it.
👍 1