章节目录:

本课程将向您介绍如何从命令行运行测试,这允许您配置 SOAtest,以便在每晚指定的时间(或任何其他需要的间隔)自动检查整个项目。这确保测试始终如一地进行,而不会造成干扰。 

SOAtest 的命令行模式允许从 Windows 或 UNIX 命令行 shell 执行测试,并从 Ant、Maven 和 CruiseControl 等自动化构建实用程序运行 SOAtest。 

下面的练习旨在演示使用 soatestcli 的基础知识。

重要项

使用 soatestcli 需要一个命令行许可证。本许可证提供了 SOAtest 自动化版本。

从命令行运行测试套件

在本例中,我们将通过命令行运行 SOAtestTutorial.tst,该命令行可以在 examples 目录中找到。

  1. 关闭 SOAtest 并打开命令行窗口。
  2. 切换到安装 SOAtest 的目录。
  3. 在命令行窗口中输入以下命令:
    • 在 Windows 上:
      soatestcli.exe -config <configuration name> -resource "C:\Location Of SOAtestTutorial.tst(在默认工作空间中)" -report MySampleReport

    • 在 UNIX 上(其中 Location Of SOAtestTutorial.tst 表示 SOAtest 在磁盘上的位置):
      soatestcli -config <configuration name> -resource "/Location Of SOAtestTutorial.tst(在默认工作空间中)" -report MySampleReport

例如:
soatestcli.exe -config “user://Example Configuration” -resource “user://Examples/SOAtestTutorial.tst” -report MySampleReport

在工作空间中运行所有项目

若要在工作空间中运行所有项目,请使用 -data 选项。

soatestcli.exe -data "c:\mySOAtestWorkspace" -showdetails -config "user://Example Configuration" -report "c:\mySOAtestReports"

这个 –data 选项指定 Eclipse 工作空间位置。

这个 –showdetails 选项打印详细的测试进度信息。

这个 –config 选项指定测试配置。

这个 –report 选项生成 HTML 报告。

在工作空间中运行单个项目

若要在工作空间中运行单个项目,必须使用 -resource 选项指定要测试的项目:

soatestcli.exe -data “C:\mySOAtestWorkspace” -resource “MyProject” -exclude “MyProject/somebadtesttoskip.tst” -showdetails -config “user://Example Configuration” -report “C:\mySOAtestReports”

这个 -exclude 选项指定测试期间要排除的文件。

使用设置文件

设置文件可以控制报告设置、DTP 设置和错误作者设置等。您可以为不同的项目创建不同的设置文件,然后使用 -settings 选项指示应将哪个文件用于当前命令行测试。

设置文件必须是一个简单的文本文件。没有任何名称或位置要求。每个设置应该在一行中输入。 

如果一个参数已在该文件中指定,则它将覆盖 GUI 中指定的相关参数。如果在此文件中没有指定参数,则 SOAtest 将使用 GUI 中指定的参数。

soatestcli.exe -data "c:\mySOAtestWorkspace" -showdetails -config "user://Example Configuration" -report "c:\mySOAtestReports" -publish -settings "c:\mysettings.properties"

下面是一个设置文件示例(该文件必须根据您的环境自定义):

concerto.reporting=true
dtp.url=http://dtp.server.com:32323
report.dtp.publish=true
concerto.log_as_nightly=true
report.mail.enabled=true
report.mail.server=smtp.server.com
report.mail.domain=server.com
report.mail.subject=My Nightly Tests
[email protected]
report.mail.exclude.developers=false
scope.sourcecontrol=true
scope.local=false
soatest.license.use_network=true
soatest.license.network.url=http://ls.server.com:8443
soatest.license.network.edition=server_edition

从命令行将环境配置应用到回归测试

环境最大优点之一便是能够从命令行重新运行相同的回归套件,而无需打开 SOAtest GUI 并修改主机或 URL 设置。

首先,按照在不同的环境中运行测试中描述的设置环境。 

接下来,从命令行运行如下命令:

soatestcli.exe -config <configuration name> -resource <path to test suite name.tst relative to the workspace> -environment "Default Calculator Environment"

最后,使用如下命令切换环境:
soatestcli.exe -config <configuration name> -resource <path to test suite name.tst relative to the workspace> -environment "Echo Environment"

这将使用应用于它的第二个环境运行相同的套件。

  • No labels