2017-04-05 88 views
4

我是Specflow和BDD的粉丝。它在各种项目中对我很有帮助。组织特征文件的最佳方式是什么?

我还没有解决的一个挑战是以某种方式组织我的功能文件和场景,这使得它很容易浏览和探索。想象一年后,别人想要一起来了解这个系统。从哪儿开始?最重要的是什么不重要?特征之间的任何关系?系统是否处理特定情况?作者有没有想过这个问题?

任何人都可以分享一些技术,阅读或工具,哪些重点?

回答

5

这个问题真的是关于个人喜好,但我的答案是我如何让我的目录更容易理解。

随着我一直在努力的项目,我不得不考虑这样的问题。我知道后面的内容,其他人会浏览黄瓜目录以添加更多或者修复各种bug。

一般来说,我们采取这种做法(我会用我们的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   

说你是新的项目,所以你要找出什么情况下有已被写入。 您知道它是功能集的一部分,所以您沿着这条路线前进,您正在寻找功能文件,以便沿着这条路线前进。您有兴趣了解安全性是如何针对搜索功能进行测试的,因此您需要进入并找到该文件。

在我们的文件夹结构的其余部分,这是相同的理论。一切都正是你所期望的。

+1

谢谢凯尔,那非常有帮助。所以你通过在文件夹结构和功能分解中加入更多思想和纪律来实现秩序。功能和步骤与软件组件结构保持一致。功能文件按其常用的特定方面进行细分。步骤定义按照功能文件名称分组在文件中。我想这需要一定的训练才能保持全部同步?我会尝试重构的一部分。 – Pasho

+0

它确实需要纪律,但团队中的人员明白在目录周围移动是多么容易。 我们也一直在试图使我们的套件尽可能地保持可读性,使用JS对象和黄瓜表达式而不是粗糙的正则表达式。 C#中的等价物可以是[下划线](http://specflow.org/documentation/Step-Definition-Styles/)和[ExpandoObjects](http://stackoverflow.com/questions/6625907/javascript-var-obj-新对象的等效在-C-尖锐)。人类的可读性是一件很好的事情,因为它减少了新手和项目之间的差距。 –

+0

您还会注意到,有些情况下您无需添加新文件。在我的例子中,你可以看到'homepage_check_welsh_translation.feature',但没有威尔士语的翻译步骤。这在实践中发生了很多。我在'home_steps.js'中写过的步骤 - 在这种情况下会很快适用于威尔士语翻译,但是由于它们在技术上是两个不同的功能,我会将功能文件分开。 如果我想添加一个我仅用于威尔士语翻译的新步骤,那么在这种情况下,我会创建一个新的步骤文件。 –

相关问题