Replies: 3 comments 14 replies
-
Hi @bmmptlgc , If you would like to perform unit testing, you can use the Today all kafka supplier are internals, mainly because So my recommendation is :
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I finally nailed it! And only by changing Here is how I solved my schema registry issue:
I am also stopping my hosted service now, so that the streaming service doesn't keep running in the background after my test assertion. So, yeah, I would love if you didn't mind making those classes public 😄 |
Beta Was this translation helpful? Give feedback.
-
Hi, I created a streaming app that reads messages from a multi schema topic and sends each message type to it's own topic, filtering out messages types that we don't want to stream. Here's the repo: https://github.com/bmmptlgc/TopicSplitter/tree/master
I am trying to figure out how to unit tests (not integration tests). I was hoping I could inject
IKafkaSupplier
intoKafkaStreamingService
:And pass it to
KafkaStream
:In my
Startup.cs
I would add the KafkaSupplier as a Singleton:And then in my unit test I would configure my DI by replacing the IKafkaSupplier above with
MockKafkaSupplier
, so my tests would run with mocks and not the real thing. I could even try using Moq to mock IKafkaSupplier.But
DefaultKafkaClientSupplier
is internal. What a pity :(If all the above was possible, I could endeavor to test the behavior of my app to simulate that a message was consumed and then assert on my mock that it "was published" (not for real cuz it's a unit test using a mock) to the correct topic name and with the correct payload. I could repeat this to test all the behaviors of my app by running the actual app and not testing implementation.
On the other end, I'm not 100% sure if this would work even if DefaultKafkaClientSupplier was public, but I would certainly love to give it a try.
I couldn't find any unit tests in
https://github.com/LGouellec/kafka-streams-dotnet-samples
. What testing approaches would be suggested for my application?Beta Was this translation helpful? Give feedback.
All reactions