[FitNesse|cucumber]FitNesse与cucumber行为驱动测试开发的典范

简介:
I was recently tasked with piloting a couple of design tools designed to help us with our development. 
The first one was FitNesse, and the second Cucumber with Groovy. 

The problem with “cutting edge” pieces of software tooling is that the tutorials are often up to the mercy of those who pioneered it. This is not always a good thing. In fact unless they are communicative experts its a bad thing; its a bad thing because the guys who come up with this magnificent software aren’t always the same as the guys who are able to write the best tutorials, and explain the simplest concepts (or see the need to). 


Quote: 

“FitNesse is a software development collaboration tool 
Great software requires collaboration and communication. FitNesse is a tool for enhancing collaboration in software development. 

FitNesse enables customers, testers, and programmers to learn what their software should do, and to automatically compare that to what it actually does do. It compares customers’ expectations to actual results. 

It’s an invaluable way to collaborate on complicated problems (and get them right) early in development” 

Well righto! thats right and its also correct, so what is it? 

Well its this diagram and this is the truth: 


So what is it? (Those who remember Cat in Red Dwarf a cult tv comedy classic ) 

In one sentence: 

Its a wiki, that enables a BA to put in expected outputs given inputs, which plugs into an easily codable Java adaptor designed to plug the values into your system. (ah why didn’t you say so) 

What do you need? 

Developers willing to code adaptor classes that populate your business objects/services using setters and getters. 
BA’s willing to use the wiki, and learn its own little language syntax. 

Setup 

Overall it was quite straightforwards to setup, I found the options were not amazingly intuitive but after a while I got the hang of it, and its nice to see the green filling in the boxes to show your adaptor (fixture) class is discovered and tests passed. 


What is Cucumber and Groovy? 

Well seems a little simpler from the outset but it has no wiki. The idea is: 

1: Describe behaviour in plain text 
2: Write a step definition in Ruby 
3: Run and watch it fail 
4. Write code to make the step pass 
5. Run again and see the step pass 
6. Repeat 2-5 until green like a cuke 
7. Repeat 1-6 until the money runs out 

Ah looks good except for the Ruby bit because I have Groovy, and that took long enough to get working. Good news comes in the form of cuke4duke which gets Cucumber to work with Groovy. 
Fortunately the guy who did it had some examples underneath the tutorial (Aslak Hellesoy) and I was eventually able to piece together some command line prompt uses from elsewhere on the net. 

So what is Cucumber and Groovy in my words? 

Cucumber involves a form of structured english language in the form of a scenario or set of scenarios. 

eg: 

Feature: BMI Calculator Feature 
In order to ensure that my BMI calculator 
As a Moderately Overweight Developer 
I want to run a cucumber test find out if it works or sucks 

Scenario: Robert thorough 
Given I have entered Robert as a name 
And I have entered 5 in feet 
And I have entered 9 in inches 
And I have entered 190 in pounds 
When I call calculateBMIService 
Then the stored result should be 28.1 
And the stones should be 13 Stones 

Groovy then receives these instructions and using regex sneakily uses the JVM (without compilation need) to test the assertions. 

eg. 

Before() { 
input = new com.rob.calculators.BMICalculatorInput(); 
output = new com.rob.calculators.BMICalculatorOutput(); 
bmiCalculator = new com.rob.calculators.BMICalculator(); 
} 

Given(~"I have entered (.*) as a name") { String name -> 
input.setName(name) 
} 

Setup 

I found it a little trickier and slightly frustrating to setup in terms of command line stuff, but I eventually got there, configuration is the bane of me so this is where I am most likely to get frustrated and give up, but after I got there it seemed to behave itself! 

and thats it. 

What do I prefer? hmm JUnit, maybe thats because I am willing to sit with a BA/Tester/Person and write the unit tests so theres a bit of affinity bias there 

I actually like them both, but I would say that Cucumber may edge it, for the domain language used will help slightly more in delivering business value, but I would expect both of these to evolve over the coming months and couple of years to something where both are better than either of them now. The only thing that put me off about the domain language of FitNesse was the use of “Fixtures”, quite obvious when you know but not when you don’t, remember its about selling this to those who are new to the product. If they had said the slightly more wordy “Custom Static Adaptor” then as a Java guy I’d know about it, and as it in my case is written in Java then thats the right domain terminology. They could have written “Custom Glue Code”, and I’d have had a better idea too, the name itself made me think that its another domain specific language with nuances I need to learn. 


These are great great tools, made by extremely intelligent people (far more than myself) but often they dont have the time to sell it / package it / sugar coat it into something that will be found easy by all those invovled in using it, and by that I am talking business and BA’s. 

Its one thing creating an expert tool/concept/idea, but if you can explain with examples in a really simple manner then it makes the job easier for people who come across the tool (who may not have fantastic communication/selling skills) who want to adopt agile and are also trying to sell to their bosses so they can get top down buy in. 

In balance now I know them a little more I’d be comfortable with using them both, in fact I would try them both rather than reccomend one of them, each project team has a slightly different domain, and remember we are into writing really good software, whatever tool works best we use. If the company is “wiki-mad” and the requirements are less wordy and more calculative and the Java developers very enthusiastic then there is no reason FitNesse wont work well. If you already use Groovy it may be a mistake to go towards FitNesse, but still try both and see! Experiment! 

转载别人的文章注明了出处:http://blog.agile78.co.uk/?p=171
目录
相关文章
|
7月前
|
人工智能 自然语言处理 测试技术
从人工到AI驱动:天猫测试全流程自动化变革实践
天猫技术质量团队探索AI在测试全流程的落地应用,覆盖需求解析、用例生成、数据构造、执行验证等核心环节。通过AI+自然语言驱动,实现测试自动化、可溯化与可管理化,在用例生成、数据构造和执行校验中显著提效,推动测试体系从人工迈向AI全流程自动化,提升效率40%以上,用例覆盖超70%,并构建行业级知识资产沉淀平台。
从人工到AI驱动:天猫测试全流程自动化变革实践
|
10月前
|
数据采集 人工智能 监控
人工智能驱动的软件工程:测试左移的崛起价值
本文探讨了人工智能驱动下测试左移理念在软件工程中的重要性,分析测试工程师在需求评估、AI代码生成及遗留系统优化中的关键作用,揭示AI带来的挑战与机遇,并指出测试工程师需提升技能、关注合规与可维护性,以在AI时代保障软件质量。
513 89
|
人工智能 自然语言处理 JavaScript
测试工程师要失业?Magnitude:开源AI Agent驱动的端到端测试框架,让Web测试更智能,自动完善测试用例!
Magnitude是一个基于视觉AI代理的开源端到端测试框架,通过自然语言构建测试用例,结合推理代理和视觉代理实现智能化的Web应用测试,支持本地运行和CI/CD集成。
2155 15
测试工程师要失业?Magnitude:开源AI Agent驱动的端到端测试框架,让Web测试更智能,自动完善测试用例!
|
机器学习/深度学习 人工智能 自然语言处理
探索软件测试的未来:AI 驱动的自动化测试方法
【5月更文挑战第29天】随着人工智能(AI)技术的不断发展和成熟,其在软件测试领域的应用也日益广泛。本文旨在探讨 AI 如何改变软件测试的面貌,特别是自动化测试方法。我们将分析当前自动化测试的挑战,并介绍 AI 如何提供解决方案,包括智能化测试用例生成、测试执行优化、以及结果分析等。通过实际案例研究,我们还将讨论 AI 在提高测试效率、减少错误和提升软件质量保障中的作用。最后,文章将预测 AI 在自动化测试领域的未来趋势,并提出对测试工程师的建议。
|
数据采集 人工智能 自然语言处理
Midscene.js:AI 驱动的 UI 自动化测试框架,支持自然语言交互,生成可视化报告
Midscene.js 是一款基于 AI 技术的 UI 自动化测试框架,通过自然语言交互简化测试流程,支持动作执行、数据查询和页面断言,提供可视化报告,适用于多种应用场景。
4270 1
Midscene.js:AI 驱动的 UI 自动化测试框架,支持自然语言交互,生成可视化报告
|
测试技术 Python
自动化测试项目学习笔记(一):unittest简单运行(初始化,清除,设置测试行为)
本文介绍了Python的unittest框架的基础用法,包括测试初始化(setup)、清除(tearDown)函数的使用,以及assertEqual和assertGreaterEqual等断言方法,并展示了如何创建测试用例,强调了测试函数需以test_开头才能被运行。
328 1
自动化测试项目学习笔记(一):unittest简单运行(初始化,清除,设置测试行为)
|
机器学习/深度学习 人工智能 自然语言处理
智能化软件测试:AI驱动的自动化测试策略与实践####
本文深入探讨了人工智能(AI)在软件测试领域的创新应用,通过分析AI技术如何优化测试流程、提升测试效率及质量,阐述了智能化软件测试的核心价值。文章首先概述了传统软件测试面临的挑战,随后详细介绍了AI驱动的自动化测试工具与框架,包括自然语言处理(NLP)、机器学习(ML)算法在缺陷预测、测试用例生成及自动化回归测试中的应用实例。最后,文章展望了智能化软件测试的未来发展趋势,强调了持续学习与适应能力对于保持测试策略有效性的重要性。 ####
|
机器学习/深度学习 数据采集 人工智能
探索AI驱动的自动化测试新纪元###
本文旨在探讨人工智能如何革新软件测试领域,通过AI技术提升测试效率、精准度和覆盖范围。在智能算法的支持下,自动化测试不再局限于简单的脚本回放,而是能够模拟复杂场景、预测潜在缺陷,并实现自我学习与优化。我们正步入一个测试更加主动、灵活且高效的新时代,本文将深入剖析这一变革的核心驱动力及其对未来软件开发的影响。 ###
|
XML Java Maven
在 Cucumber 测试中自动将 Cucumber 数据表映射到 Java 对象
在 Cucumber 测试中自动将 Cucumber 数据表映射到 Java 对象
393 7
|
存储 测试技术 数据库
数据驱动测试和关键词驱动测试的区别
数据驱动测试 数据驱动测试或 DDT 也被称为参数化测试。
419 1