组织功能文件的最佳方式是什么?
What's the best way to organize feature files?
我尚未解决的一个挑战是以某种方式组织我的功能文件和场景,这使得在 Specflow 和 BDD 中导航和探索变得容易。
想象一下,一年后有人想来了解这个系统。从哪儿开始?什么最重要,什么不那么重要?特征之间有什么关系?系统是否处理特定场景?作者有没有想过这个问题?
任何人都可以分享一些专注于此的技术、读物或工具吗?
这个问题确实是关于个人喜好的,但我的回答是如何让我的目录更容易理解。
在我一直从事的项目中,我不得不考虑很多这样的问题。我知道稍后,其他人会查看黄瓜目录以添加更多内容或进行各种错误修复。
一般来说,我们采用了这种方法(我将以我们的 CucumberJS 结构为例):
project
| features
| | elements
| | | pages
| | | | home.js
| | | | index.js // grab all of the things in the pages directory
| | | | search.js
| | | index.js // grab everything in elements directory and the index of pages
| | | urls.js
| | | test_customers.js
| | feature_files
| | | home
| | | | homepage_links.feature
| | | | homepage_accessibility.feature
| | | | homepage_check_welsh_translation.feature
| | | search
| | | | search.feature
| | | | search_security.feature
| | step_definitions
| | | common // Won't go into this, but we have a library of reusable steps and functions in here for different projects that we can just port over from git
| | | project
| | | | pages
| | | | | search
| | | | | | search_steps.js
| | | | | | search_security_steps.js
| | | | | home
| | | | | | home_steps.js
| | | | | | home_accessibility_steps.js
| | | | navigation_steps.js
| | | | login_steps.js
| | support
| | | env.js // Timeouts
| | | hooks.js // Setup/Teardown for scenarios
| | | world.js // Setting up the drivers
| reports
| | 2017
| | | 03
| | | | 05
| | | | | report.html
| | | | | report.js
| | | | 06
| | | | | report.html
| | | | | report.js
| | | | 07
| | | | | report.html
| | | | | report.js
| | report.json
| screenshots
| | failed
| | | 2017-03-05
| | | | search_security_xss_204057.png
| | | 2017-03-06
| | | | search_security_xss_100532.png
| | | | search_security_xss_101054.png
| | | | search_security_xss_101615.png
| | search_security
| | | 2017-03-06
| | | | search_security_xss_100528.png
| | | | search_security_xss_101050.png
| | | | search_security_xss_101611.png
| | | | search_security_xss_101841.png
| .gitignore
| README.md
假设您是一个项目的新手,所以您想了解已经编写了哪些场景。
你知道它是功能集的一部分,所以你沿着那条路走,你正在寻找功能文件,所以你沿着那条路走。您对如何针对搜索功能测试安全性感兴趣,因此您进入那里并找到该文件。
我们其余的文件夹结构都是同样的理论。一切都如您所愿。
我的方法是按端点操作的用户类型进行组织:Application/Page,因为从根本上说,测试是检查每个 restful API 是如何被谁调用的where/when.
就我个人而言,与 Cucumber 相比,我更喜欢 Robot Framework。
这是一个很大的问题,我认为我没有直接的答案,但这里有一些帮助我们制定功能文件的注意事项。这在很大程度上取决于偏好和项目的具体需求。
专题文件与用户故事不同。
来自 Matt Wynne(黄瓜书的作者)的 this excellent article:
When Aslak created Cucumber, he renamed the files from .story to .feature. This wasn’t an accident or an idle act of whimsy: it’s because there’s a difference.
User Stories are a planning tool. They exist until they’re implemented, and then they disappear, absorbed into the code.
Cucumber features are a communication tool. They describe how the system behaves today, so that if you need to check how it works, you don’t need to read code or go punching buttons on the live system. Organising your features according to the way they were planned and implemented is a distraction from this purpose.
编写包含大量业务语言的声明性功能文件可能会使您的场景比完美的目录结构更容易被发现
随着项目的增长(越来越多的人开始参与),直接浏览场景位置变得越来越困难。下一个最好的事情?寻找它。如果您的场景更具声明性且命令性更少,那么这会更容易。来自 this article from SauceLabs:
Tests should largely focus on what needs to be accomplished, not the details of how it is done. They should mostly be understandable when read by non-developers.
在更高抽象层次上编写的紧凑场景的好处在于,您可以在它开始感到拥挤之前将更多场景放入功能文件中。对于系统测试,我们很幸运将高级小黄瓜与页面对象模式配对,因为它为所有细节提供了一个层。
场景和功能如果使用与UI
相同的业务语言,则更容易找到
如果您在 UI 中有一个名为“删除”的操作,在测试中有一个名为“删除”的操作,在生产代码中有一个名为“存档”的操作,那么开发人员或业务人员可能很难找到与该操作相关的场景。如果测试始终遵循 UI(假设使用 BDD 工具的普通团队成员对 UI 比源代码更熟悉),则可能更容易搜索场景。
我尚未解决的一个挑战是以某种方式组织我的功能文件和场景,这使得在 Specflow 和 BDD 中导航和探索变得容易。
想象一下,一年后有人想来了解这个系统。从哪儿开始?什么最重要,什么不那么重要?特征之间有什么关系?系统是否处理特定场景?作者有没有想过这个问题?
任何人都可以分享一些专注于此的技术、读物或工具吗?
这个问题确实是关于个人喜好的,但我的回答是如何让我的目录更容易理解。
在我一直从事的项目中,我不得不考虑很多这样的问题。我知道稍后,其他人会查看黄瓜目录以添加更多内容或进行各种错误修复。
一般来说,我们采用了这种方法(我将以我们的 CucumberJS 结构为例):
project
| features
| | elements
| | | pages
| | | | home.js
| | | | index.js // grab all of the things in the pages directory
| | | | search.js
| | | index.js // grab everything in elements directory and the index of pages
| | | urls.js
| | | test_customers.js
| | feature_files
| | | home
| | | | homepage_links.feature
| | | | homepage_accessibility.feature
| | | | homepage_check_welsh_translation.feature
| | | search
| | | | search.feature
| | | | search_security.feature
| | step_definitions
| | | common // Won't go into this, but we have a library of reusable steps and functions in here for different projects that we can just port over from git
| | | project
| | | | pages
| | | | | search
| | | | | | search_steps.js
| | | | | | search_security_steps.js
| | | | | home
| | | | | | home_steps.js
| | | | | | home_accessibility_steps.js
| | | | navigation_steps.js
| | | | login_steps.js
| | support
| | | env.js // Timeouts
| | | hooks.js // Setup/Teardown for scenarios
| | | world.js // Setting up the drivers
| reports
| | 2017
| | | 03
| | | | 05
| | | | | report.html
| | | | | report.js
| | | | 06
| | | | | report.html
| | | | | report.js
| | | | 07
| | | | | report.html
| | | | | report.js
| | report.json
| screenshots
| | failed
| | | 2017-03-05
| | | | search_security_xss_204057.png
| | | 2017-03-06
| | | | search_security_xss_100532.png
| | | | search_security_xss_101054.png
| | | | search_security_xss_101615.png
| | search_security
| | | 2017-03-06
| | | | search_security_xss_100528.png
| | | | search_security_xss_101050.png
| | | | search_security_xss_101611.png
| | | | search_security_xss_101841.png
| .gitignore
| README.md
假设您是一个项目的新手,所以您想了解已经编写了哪些场景。 你知道它是功能集的一部分,所以你沿着那条路走,你正在寻找功能文件,所以你沿着那条路走。您对如何针对搜索功能测试安全性感兴趣,因此您进入那里并找到该文件。
我们其余的文件夹结构都是同样的理论。一切都如您所愿。
我的方法是按端点操作的用户类型进行组织:Application/Page,因为从根本上说,测试是检查每个 restful API 是如何被谁调用的where/when.
就我个人而言,与 Cucumber 相比,我更喜欢 Robot Framework。
这是一个很大的问题,我认为我没有直接的答案,但这里有一些帮助我们制定功能文件的注意事项。这在很大程度上取决于偏好和项目的具体需求。
专题文件与用户故事不同。
来自 Matt Wynne(黄瓜书的作者)的 this excellent article:
When Aslak created Cucumber, he renamed the files from .story to .feature. This wasn’t an accident or an idle act of whimsy: it’s because there’s a difference.
User Stories are a planning tool. They exist until they’re implemented, and then they disappear, absorbed into the code.
Cucumber features are a communication tool. They describe how the system behaves today, so that if you need to check how it works, you don’t need to read code or go punching buttons on the live system. Organising your features according to the way they were planned and implemented is a distraction from this purpose.
编写包含大量业务语言的声明性功能文件可能会使您的场景比完美的目录结构更容易被发现
随着项目的增长(越来越多的人开始参与),直接浏览场景位置变得越来越困难。下一个最好的事情?寻找它。如果您的场景更具声明性且命令性更少,那么这会更容易。来自 this article from SauceLabs:
Tests should largely focus on what needs to be accomplished, not the details of how it is done. They should mostly be understandable when read by non-developers.
在更高抽象层次上编写的紧凑场景的好处在于,您可以在它开始感到拥挤之前将更多场景放入功能文件中。对于系统测试,我们很幸运将高级小黄瓜与页面对象模式配对,因为它为所有细节提供了一个层。
场景和功能如果使用与UI
相同的业务语言,则更容易找到如果您在 UI 中有一个名为“删除”的操作,在测试中有一个名为“删除”的操作,在生产代码中有一个名为“存档”的操作,那么开发人员或业务人员可能很难找到与该操作相关的场景。如果测试始终遵循 UI(假设使用 BDD 工具的普通团队成员对 UI 比源代码更熟悉),则可能更容易搜索场景。