#1304

Writing UI tests in Rust for a Qt application?

Openfaernopened 1y ago

I'm unable to find any information on the topic. If we were to develop a desktop application in Rust using this library, what are our options with regards to UI testing? Would they need to be implemented in C++ according to the official Qt Test documentation? Or is it possible to perform UI testing at some level from Rust in an efficient manner?

Activity

4
faern1y ago

Python has good bindings to Qt and seem to have good test writing possibilities. Is it possible to write UI tests in python for a Rust-Qt application maybe?

ahayzen-kdab1y ago

For UI tests, I would just write them in the normal way in C++ or in QML using Qt Test or Qt Quick Test. From the perspective of Qt any CXX-Qt QML modules or QObject classes you make are "normal". So then you can make use of the helpers in the Qt Testing libraries.

Then for any logic or unit tests of Rust specific things you can use cargo/rust tests as normal too.

If you look through our examples and crates you can see how we have a mix of cargo tests and Qt tests where appropriate.

faern1y ago

Thanks for the reply! We will explore the options you list (except C++) in a little PoC and see what works. I'm asking from a perspective of a team who considers re-writing a desktop app UI in Qt via Rust. The team wants to work in a rather test driven fashion and has knowledge in Rust and web technology, but does not and will not be working with C++.

ahayzen-kdab1y ago

I would be potentially cautious if attempting to use Qt with no C++ at all, as when reading documentation or doing anything advanced you are likely going to either need C++ knowledge or potentially write some C++. If you are looking for a pure Rust solution with no C++, then things like Slint, egui, iced tend to be better.