Unit testing without a real rabbitmq instance

Hi,

I am writing pytest based unit tests for my nameko services as outlined here: Testing Services — nameko 2.12.0 documentation. I’ve been using container_factory for testing my services for the most part. A few instances where I’ve used worker_factory.

However, it looks like there is no way I can execute these tests without a real rabbitmq instance. This is forcing us to tweak our CI infrastructure to accommodate this.

Is there a way to execute nameko unit tests without a real rabbitmq instance?

Thanks,
Radha

For Unit testing, you can use worker_factory and test without RabbitMQ.

For Integration Testing, container_factory can spawn multiple services and communicate within them, that’s why it needs a RabbitMQ connection.

Is there a reason you need container_factory for Unit Testing? You could spawn more than one instance with worker_factory, although without communication within them.

1 Like

for unit testing you can use the decorator:

nameko.config.patch({"AMQP_URI": "memory://"})

to test events without having a real MQ instance.

1 Like