组织功能文件的最佳方式是什么?组织、功能、方式、文件

2023-09-07 23:52:20 作者:勿忘年少*

我尚未解决的一个挑战是以某种方式组织我的功能文件和场景,以便在 Specflow 和 BDD 中轻松导航和探索.

One challenge I haven't solved yet is organizing my feature files and scenarios in a way, which makes it easy to navigate and explore in Specflow and BDD.

想象一年后有人想来了解这个系统.从哪儿开始?什么最重要,什么不重要?特征之间有什么关系吗?系统是否处理特定场景?作者有没有想过这个问题?

Imagine one year later someone else wants to come along and learn about the system. Where to start? What's most important, what's less important? Any relations between features? Does the system handle a particular scenario? Has the author thought about this problem?

谁能分享一些专注于此的技术、阅读或工具?

Can anyone share some techniques, reads or tools, which focus on that?

推荐答案

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

This question really is about personal preference, but my answer is how I make my directories easier to understand.

对于我一直从事的项目,我不得不考虑很多类似的问题.我知道以后,其他人会查看 cucumber 目录以添加更多内容或进行各种错误修复.

With the projects that I've been working on, I've had to think about problems like this quite a bit. I know that later down the line, other people will look through the cucumber directories to add more or do various pieces of bug fixing.

一般来说,我们都是采用这种方式(我以我们的CucumberJS结构为例):

Generally speaking, we have taken this approach (I'll use our CucumberJS structure as an example):

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         

假设您是一个项目的新手,因此您想了解编写了哪些场景.你知道它是特性集的一部分,所以你沿着那条路线走,你正在寻找特性文件,所以你沿着那条路线走.您对如何测试搜索功能的安全性感兴趣,因此您进入那里并找到文件.

Say you're new to a project, so you want to find out what scenarios have been written. You know it's part of the feature set, so you go down that route, you're looking for the feature file, so you go down that route. You're interested in how the security has been tested for the search feature, so you go into there and locate the file.

我们的文件夹结构的其余部分都是相同的理论.一切都如您所愿.

It's the same theory throughout the rest of our folder structure. Everything is exactly where you'd expect it to be.