编码的 UI 测试 - 将 exe 文件作为清理脚本运行

发布于 2024-11-16 13:39:51 字数 462 浏览 0 评论 0原文

我正在尝试从每次测试运行后生成的已完成测试 .trx 文件自动生成 .pdf 文件。我创建了一个 .exe,它可以获取这个 trx 文件并将其转换为 pdf。当我单独运行该应用程序时,它工作正常,但是当我尝试将其用作清理脚本时,我遇到了麻烦。测试运行良好,并生成了测试结果文件,但是当它运行清理方法时,它似乎找不到测试结果文件。

我也尝试过使用 AssemblyCleanup() 方法,但这会产生类似的错误。

[TestClass]
public static class AssemblyClean
{
    [AssemblyCleanup()]
    public static void AssemblyCleanup()
    {
        System.Diagnostics.Process.Start("XMLtoPDFConverter.exe");
    }
}

任何帮助将不胜感激,谢谢。

I'm trying to automatically generate a .pdf file from the completed test .trx file that is generated after every test run. I created a .exe that can take this trx file and convert it into a pdf. The application works fine when i run it on its own, but im having trouble when i try and use it as a cleanup script. The test runs fine, and generated the test results file, but when it runs the cleanup method it cant seem to find the test results file.

I've also tried using the AssemblyCleanup() method but that is producing a similar error.

[TestClass]
public static class AssemblyClean
{
    [AssemblyCleanup()]
    public static void AssemblyCleanup()
    {
        System.Diagnostics.Process.Start("XMLtoPDFConverter.exe");
    }
}

Any help would be appreciated, thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅浅 2024-11-23 13:39:51

直到一切运行之后,测试结果文件可能才会被创建。尝试在 XMLtoPDFConverter.exe 中设置 5 或 10 秒的睡眠。这样,您的进程将由 AssemblyCleanup() 启动,但在有足够的时间创建 .trx 文件之前,它不会查找 .trx 文件。

The test results file is probably not being created until after everything runs. Try putting a 5 or 10 second Sleep in your XMLtoPDFConverter.exe. That way, your process will be started by the AssemblyCleanup(), but it won't look for the .trx file until after there's been enough time for it to be created.

小姐丶请自重 2024-11-23 13:39:51

似乎所需要做的就是关闭解决方案并重新打开它。这似乎使 Visual Studio 能够识别 exe 文件。每当我更改 exe 文件时,我都必须做同样的事情。另外,对于将来遇到类似问题的任何人,我坚持使用 AssemblyCleanup() 方法,并且在每次测试运行后执行得很好,无论成功与否。

It seems that all that was necessary was to close the solution and reopen it. This seems to of made visual studio recognize the exe file. I have to do the same thing whenever i make changes to the exe file. Also for anyone that runs into a similar issue in the future, I stuck with the AssemblyCleanup() method and that executes just fine after every test run, successful or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文