How to mock a QML component
问题 Actually I'm trying to run some test on a QML component which embeds C++ objects. Unfortunately, I'm getting some errors when I execute my tests. The C++ objects aren't recognized by the QML file. That makes also sense as the C++ objects are set in the main.cpp file. My question is: How can I mock an context property for performing QML tests? Or other said, how can I do unit-test with mixing Qt/QML code? 回答1: As I understand you right, you got same problem as I. Some time ago I wrote this