Question

How does one test a method that does some interactions with the local D-Bus (accessing a HAL object)?

Results of tests will differ depending on the system that the test is run on, so I don't know how to provide the method reliable input.

I'm working in Python, by the way.

Was it helpful?

Solution

If you can not mock the environment then it's probably impossible for you to write the test. If your access to HAL/D-Bus is via an object and you provide a mock instance to your test then it should be possible to emulate the necessary inputs to your test from the mock implementation.

OTHER TIPS

It's also possible to create a temporary D-Bus buses for tests, and emulate any services your program uses in your test code. You can use this approach for programs which are D-Bus services, D-Bus clients, or both. The downside is that the bus setup is a bit hairy. There's code for doing this in e.g. Telepathy Gabble.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top