最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

testing - Display UI tests while testsing - Stack Overflow

programmeradmin3浏览0评论

I have a simple app that contains a button, and the content of that button changes after it is pressed (Avalonia for app and Avalonia Headless Tests for UI tests). I'm trying to make my UI tests visible for future debugging purposes, but I can't find any relevant information in the documentation to address this issue. Below is the code I'm currently working with:

Test:

[AvaloniaTest]
public void Should_Find_Button_And_Check_Text()
{
    var window = new MainWindow();
    window.Show();

    var button = window.FindControl<Button>("ClickMeButton");
    Assert.IsNotNull(button, "Кнопка ClickMeButton не найдена.");

    Console.WriteLine("Before click: " + button.Content);

    button.Command?.Execute(button.CommandParameter);
    button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));

    Console.WriteLine("After click: " + button.Content);
}

Start of testing process

[assembly: AvaloniaTestApplication(typeof(TestAppBuilder))]

public class TestAppBuilder
{
    public static AppBuilder BuildAvaloniaApp() =>
        AppBuilder.Configure<App>()
            .UsePlatformDetect()
            .UseReactiveUI()
            .SetupWithClassicDesktopLifetime(new string[0])
            .LogToTrace();
}
发布评论

评论列表(0)

  1. 暂无评论