让不懂编码的同事皆可参与开发过程,人人清晰明白用户故事,提升团队协作效率

《纽约时报》让不懂编码的同事皆可参与开发过程,将一个产品功能拆解成一句句简单易明的文字,展现一个功能在不同情景的变化,但不会阐明具体详情,只追求清晰简单易明。此方法的步骤简单,产品经理先写一个用户故事,再联同发展人员转换成一份功能文件 (Feature File),例如将故事拆分为 场景 、 假设 、 当 和 那麽 ,并以简单句子逐一描述。成品完成后,可作为有份撰写的开发人员的自动化点对点测试大纲。当点对点测试通过后,再将整个测试框架嵌入持续整合管道 (Continuous Integration Pipeline) 。降低门槛,人人清晰明白用户故事,提升团队协作效率,何乐而不为?

No Code? No Problem — Writing Tests in Plain English

The Times Open Team

open.nytimes.com

查看原始文档

Illustrations by Dalbert Vilarino

How we use Behavior Driven Development to better collaborate

By NAIDELE MANJUNATH and OLIVIER DE MEULDER

Behavior Driven Development, or BDD, is an approach to software development where the behavior of a feature is defined through examples in plain text. These examples, known as feature files, are defined before development starts and are used as acceptance criteria for new features. Written using the Gherkin language, which uses English words, the feature files are readable to anyone regardless of programming ability. Feature files are written in a “behavior-driven” style, meaning they contain details on how a feature is supposed to behave when something happens in a given situation. This behavior is the only information that is mentioned in the feature file; the underlying implementation details of the feature are not mentioned.

Our cross-functional team — the Customer Care Technology team at The New York Times — uses feature files to have deeper conversations about our product, which helps create a shared understanding of what should be developed. When everyone understands our user stories, we waste less time in the production process and have fewer instances where we redo the work we’ve done. Writing feature files together encourages collaboration, and helps developers and QA understand the business aspects of the story.

Because anyone on the team can read and write feature files, we don’t need to rely on testers or QA engineers to write the tests.

Our process

At the beginning of each sprint, our product manager writes the user stories for each feature, following Agile principles. Here is a simple example of a user story that we might include in one of our sprints:

As a customer care advocate, I want to update a customer’s credit card on file, so that the customer’s new credit card will be charged during the next billing cycle.

When the user stories have been written, our product manager and our developers sit together to translate the user stories into feature files. The feature files serve as the outline for the automated end-to-end tests that the developers are responsible for writing.

Following our example of a user story above, the feature file may look like this:

The automated tests are written in Javascript. Each Given, Whenand Then line in the feature file correspond to a simple Javascript function, and the Then line will contain the test assertion. Our team uses the Mocha assertion librarywebdriver.IO as a test runner and the Cucumber framework to interpret the test feature, but any can be used. The developer working on the automated end-to-end test can run the test locally on their machine.

And this is where the magic happens.

The test runner parses the feature file, figures out which JavaScript functions to run and reports back.

Once all the end-to-end tests pass successfully, there is one more step. The BDD testing framework is integrated in our continuous integration (CI) pipeline. This allows everyone to verify that the tests run in the staging environment.

A report from the test may look like this:

As you can see, the report is easy to read, even if you do not have a technical background.

Illustration by Dalbert Vilarino

So, what makes BDD worthwhile? Our team has seen four tangible benefits:

Increased collaboration. The product manager is involved in designing the tests, which means they work with the developers (and QA, if applicable) to clearly state the business rules. Everyone on the team has a strong understanding of new product features and the progression of the project is clearly visible to each member.

Living documentation. Because the feature files serve as the checks before features reach production, they need to be kept up-to-date. Any modifications to the product or features means that the files have to be updated to avoid failures caused by the feature definitions. While documentation is often an afterthought in software development, BDD makes it an integral part of the development process.

Quick Ramp-up. Code doesn’t make sense to everyone. It also doesn’t make good documentation. Working with team members who don’t understand code usually means that the team has to create a separate document, like a spreadsheet, to describe what is covered by the test code. BDD helps solve this problem with feature files. Newcomers to the team can read feature files and quickly understand what the feature does. This is better than going through tons of documentation.

Readable Reports. Usually, test results are not presented in a user-friendly format — a log in the report could say something cryptic like, “expected false to equal true.” Although this may be simple to read, the context or meaning is not clear to the reader: what was expected to be true and is now false? With BDD results, each result falls under the corresponding scenario in the BDD feature file, which provides better readability.

Our team started using BDD a few months ago. At first it was a bit scary and overwhelming because everyone needed to learn a new technical skill and work together in a new way. Over time, the team mastered BDD testing and found that working closely together was a very natural process. When the team collaborates on feature files, we’re more aligned on the development cycle and the product becomes better.

Naidele Manjunath is a Software Engineer with The New York Times Test Automation Team.

Olivier De Meulder is an Engineering Manager with The New York Times Subscription Platforms Group.

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,684评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,143评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,214评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,788评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,796评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,665评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,027评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,679评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 41,346评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,664评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,766评论 1 331
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,412评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,015评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,974评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,203评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,073评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,501评论 2 343

推荐阅读更多精彩内容