简体   繁体   English

在每个测试用例之后挤压关闭我的应用程序

[英]Squish close my Application after every Test Case

The testing Tool Squish closes my Application after every Test Case, How can I avoid that?测试工具 Squish 在每个测试用例之后关闭我的应用程序,我该如何避免? I even unchecked "Automatically start the AUT" and start the Application with startApplication().我什至取消选中“自动启动 AUT”并使用 startApplication() 启动应用程序。 I also tried the attachToApplication() methode without success!我也尝试了 attachToApplication() 方法但没有成功!

Thanks a lot my friends非常感谢我的朋友

Martin马丁

Basically, if you use Squish by the default or start your AUT using "startApplication", the Squish will terminate the application just after the test case. 基本上,如果您使用默认的Squish或使用“startApplication”启动您的AUT,Squish将在测试用例之后终止应用程序。

Fortunately, Squish has provided a way to fulfill your situation, that is attachToApplication . 幸运的是,Squish提供了一种方法来实现您的情况,即attachToApplication

When using this way, squish will not terminate the AUT when it finished a test case. 使用这种方式时,压缩不会在完成测试用例时终止AUT。 Referring to this link: Attaching to running applications . 参考此链接: 附加到正在运行的应用程序 There are three steps to attach the application. 附加应用程序有三个步骤。 I have checked and it works in windows platform, and I guess it will also work for other platforms. 我已经检查过它可以在Windows平台上运行,我猜它也适用于其他平台。

Start the AUT with a certain port. 使用某个端口启动AUT。 You need to start the application using the squish's application named startxxxAUT , startwinaut in windows. 您需要使用名为startxxxAUT startwinaut应用程序启动应用程序,在Windows中使用startwinaut This application is under the directory of where your Squish installed. 此应用程序位于您安装Squish的目录下。 eg <Squish-Install-DIR>/bin/startwinaut 例如<Squish-Install-DIR>/bin/startwinaut

startwinaut --port=8899 c:/Installed/notepad/notepad++.exe

Next step, register your application in squish, you can use command squishserver --config addAttachableAUT note 8899 to register your AUT. 下一步,注册您的应用程序,您可以使用命令squishserver --config addAttachableAUT note 8899注册您的AUT。 Or, you can perform this action with Squish IDE. 或者,您可以使用Squish IDE执行此操作。 <Edit>--<Server Settings>--<Manage AUTs...>--<Attachable AUTs>--<Add> . <Edit>--<Server Settings>--<Manage AUTs...>--<Attachable AUTs>--<Add> Referring to the screen shot: 参考屏幕截图: 在此输入图像描述 Please remember that the port number should match the one that you use to start your AUT. 请记住,端口号应与用于启动AUT的端口号相匹配。

The fininal step, attach the AUT in your script, like below: 最后一步,在您的脚本中附加AUT,如下所示:

def main():
    attachToApplication("note")
    snooze(10)

BTW, you can use " subprocess.popen " to execute the command " startwinaut --port=8899 c:/Installed/notepad/notepad++.exe " to start your AUT if you need to start your AUT in an automated way(Not manually typing the command). 顺便说一句,你可以使用“ subprocess.popen ”到“执行命令startwinaut --port=8899 c:/Installed/notepad/notepad++.exe ”如果你需要启动AUT以自动的方式开始新的AUT(非手工输入命令)。

Hope this will help you, thanks! 希望这对你有所帮助,谢谢!

Attachable AUT approach comes with additional effort when it comes to setting context to start test script.在设置上下文以启动测试脚本时,可附加的 AUT 方法需要额外的努力。

Putting the AUT in the right context is important for any automation test to be executed.将 AUT 放在正确的上下文中对于要执行的任何自动化测试都很重要。 Squish default behavior is to kill the application at the end of the test so it guarantees that you start and end your tests at the same point. Squish 默认行为是在测试结束时终止应用程序,因此它保证您在同一点开始和结束测试。 In the normal approach, nothing to worry about bringing the application to a common known state as it will always start by starting the application and stop by killing it.在正常方法中,无需担心将应用程序置于常见的已知状态,因为它始终以启动应用程序开始并通过终止应用程序停止。

As explained by @Lowitty, if you are to use attach to already running AUT approach (if that is what suites your need), then you must make sure to use proper cleanup steps at the end of each test which will set your AUT to initial context, so that the next test script can start over from there.正如@Lowitty 所解释的,如果您要使用附加到已经运行的 AUT 方法(如果这适合您的需要),那么您必须确保在每个测试结束时使用适当的清理步骤,这会将您的 AUT 设置为初始上下文,以便下一个测试脚本可以从那里重新开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM