my $mw = eval { MainWindow->new }; if (!$mw) { ... skip tests ... }