@@ -597,28 +597,26 @@ create test/fixtures/articles.yml
597
597
598
598
# # 系统测试
599
599
600
- 系统测试是完整的浏览器测试,可用于测试应用的 JavaScript 和用户体验。系统测试建立在 Capybara 之上。
601
-
602
- 系统测试可以在真实的浏览器中运行,也可以在无界面驱动中运行,用于测试用户与应用的交互。
600
+ 系统测试用于测试用户与应用的交互,可以在真正的浏览器中运行,也可以在无界面浏览器中运行。系统测试建立在 Capybara 之上。
603
601
604
602
系统测试存放在应用的 ` test/system` 目录中。Rails 为创建系统测试骨架提供了一个生成器:
605
603
606
604
` ` ` sh
607
- $ bin/rails generate system_test users_create
605
+ $ bin/rails generate system_test users
608
606
invoke test_unit
609
- create test/system/users_creates_test .rb
607
+ create test/system/users_test .rb
610
608
` ` `
611
609
612
610
下面是一个新生成的系统测试:
613
611
614
612
` ` ` ruby
615
613
require " application_system_test_case"
616
614
617
- class UsersCreatesTest < ApplicationSystemTestCase
615
+ class UsersTest < ApplicationSystemTestCase
618
616
# test "visiting the index" do
619
- # visit users_creates_url
617
+ # visit users_url
620
618
#
621
- # assert_selector "h1", text: "UsersCreate "
619
+ # assert_selector "h1", text: "Users "
622
620
# end
623
621
end
624
622
` ` `
@@ -644,7 +642,7 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
644
642
end
645
643
` ` `
646
644
647
- 驱动名称是 ` driven_by` 必须的参数。` driven_by` 接受的可选参数有:` :using` ,指定使用的浏览器(仅供有界面的驱动使用,如 Selenium);` :screen_size` ,修改截图的尺寸。
645
+ 驱动名称是 ` driven_by` 必须的参数。` driven_by` 接受的可选参数有:` :using` ,指定使用的浏览器(仅供 Selenium 使用 );` :screen_size` ,修改截图的尺寸; ` :options ` ,设定驱动支持的选项 。
648
646
649
647
` ` ` ruby
650
648
require " test_helper"
@@ -654,7 +652,7 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
654
652
end
655
653
` ` `
656
654
657
- 如果所需的 Capybara 配置 Rails 提供的多,可以把所有配置都放在 ` application_system_test_case.rb` 文件中。
655
+ 如果所需的 Capybara 配置比 Rails 提供的多,可以把额外配置放在 ` application_system_test_case.rb` 文件中。
658
656
659
657
其他设置参见 [Capybara 的文档](https://github.com/teamcapybara/capybara#setup)。
660
658
0 commit comments