Cypress 简明教程

Cypress - Test Runner

Cypress Test Runner 有助于触发测试执行。当我们完成 Cypress 安装后,该工具在终端上提出了建议,如下所示 -

Cypress Test Runner helps to trigger the test execution. As we complete Cypress installation, there comes a suggestion from the tool on the terminal, as mentioned below −

You can open Cypress by running − node_modules/.bin/cypress open

要打开 Test Runner,我们必须运行下面提到的命令 -

To open the Test Runner, we have to run the below mentioned command −

node_modules/.bin/cypress open

一段时间后,“测试运行器”窗口将打开,显示一条消息,即 Cypress 在 examples 文件夹中提供了示例项目文件夹结构。

The Test Runner window opens up after some time with the message that a sample project folder structure has been provided by Cypress under examples folder.

单击“确定,我知道了!”按钮。然后,计算机上将显示如下屏幕:

Click on the OK, got it! button. The screen that will appear on your computer would be as follows −

test runner

然后,测试运行器将启动,其中 examples 文件夹下提供了一个以上的 spec 文件,如下所示:

Then the Test Runner is launched, with the more than one spec files available under the examples folder, as stated below −

files

要运行特定文件,例如 test2.spec.js,我们必须单击它。此外,还提供了浏览器和停止执行的选项。

To run a specific file, for example, test2.spec.js, we have to click it. Also, the browser and the option to Stop the execution are available.

test2 spec js

执行应当从以下屏幕开始,显示测试步骤、测试用例名称、测试套件、URL、测试持续时间、浏览器尺寸,等等。

The execution shall begin with the following screen showing the test steps, name of test case, test suite, URL, test duration, dimension of browser, and so on.

dimension of browser