@GrecKo said in QSignalSpy verify emission order:
You don't have to use QSignalSpy, you could store the received signals in an ordered list:
QStringList receivedSignals;
QObject::connect(&inst, &MyClass::started, &inst, [&] { receivedSignals.append("started"); });
QObject::connect(&inst, &MyClass::finished, &inst, [&] { receivedSignals.append("finished"); });
inst.doSomething();
QStringList expectedSignals = {"started", "finished"};
QCOMPARE(receivedSignals, expectedSignals);
That makes sense. I figured that using an external mechanism would do the trick, though your idea with a lambda populating a QStringList is far simpler than what I was cooking up. I was hoping for a simple solution, and this looks like it'll be the simplest way of achieving my goal.
Thanks!