aui::uitests#
UI testing: find views, simulate user input and check what is on the screen.
Detailed Description#
aui::uitests runs your real windows and views inside a GTest test, without a native window: a stub window manager and
a software renderer are used, so tests are fast and work on a headless CI. A test finds views with By, acts on them
as a user would (click, type, scroll) and checks the result.
#include <AUI/UITest.h>
class UIGreeting : public testing::UITest {};
TEST_F(UIGreeting, Click) {
_new<MyWindow>()->show();
By::text("Say hello").perform(click());
By::name("#hello").check(visible()).check(text("Hello!"));
}
Include <AUI/UITest.h> to get everything. If your project uses aui_enable_tests and AUI was imported with the
uitests component (auib_import(aui ... COMPONENTS core views uitests)), aui::uitests is linked to the Tests
target automatically; see Writing tests for the general test setup.
Pages of this module:
- Your first UI test - fixture, window, a complete test;
- Finding views - finding views with
Byand combining matchers; - Simulating user input - clicks, typing, key presses, scrolling;
- Checking views - built-in checks, layout checks and custom assertions;
- Screenshots and pixels - pixel checks and failure reports.
testing::UITest is the base class of UI test suites, UIMatcher is the object returned by By.