[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

时间: 2024-09-27 07:49:19

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

camera驱动-A31s的ov5640驱动测试时黑屏问题

问题描述 A31s的ov5640驱动测试时黑屏问题 用相机软件打开后一片黑,看不到图像,MCLK,PCLK,VSYNC有信号,HSYNC正负都有峰峰值1.8V,数据线有信号,物体接近时能看到明显变化.开机信息提示如下:[ 113.532510] [VFE]vfe_open[ 113.532710] [VFE]vfe_open ok[ 113.532753] [OV5640]CSI_SUBDEV_STBY_OFF![ 113.532776] [VFE]mclk on[ 113.555791] [O

《测试驱动数据库开发》目录—导读

版权声明 测试驱动数据库开发 Authorized translation from the English language edition, entitled Test-Driven Database Development: Unlocking Agility, 9780321784124 by Max Guernsey, III, published by Pearson Education, Inc., publishing as Addison-Wesley, Copyright 2

《测试驱动数据库开发》—第2章2.1节TDD中类的角色

第 2 章 建立数据库的类 测试驱动数据库开发 开始测试驱动数据库时,需要做的第一件事是定义数据库的类,并且不用过多地担心特定的数据库实例.读完本书后,读者将有可能开始从允许任意的手工修改,转变到允许保持任意有意义的数据库实例.为了帮读者达到这个目的,本章将深入讨论什么是类以及类如何能够提供帮助,还将深入探讨在数据库开发中的影响力是如何不同于应用程序开发的影响力的. 在调和了类的本质与在数据库开发中出现的新的影响力之后,本章展现了一个数据库的类的需求,并展示了如何实现该需求.希望能为开发者提供与

《测试驱动数据库开发》——2.1 TDD中类的角色

2.1 TDD中类的角色 测试驱动数据库开发 在测试驱动开发中,一个类的主要作用是提供一种机制,以便许多具有相同行为的对象能够被创建.这一点非常重要,因为测试软件的方式就是通过检查一个单独对象的行为,并据此来预知从该对象的类生成的所有其他实例的行为. 当没有类时,测试仅仅告诉开发者有关某个特定对象的情况.当有了类时,测试会告诉开发者有关对象将如何被创建的情况,并进一步告诉开发者所有其他对象将如何被创建的情况. 2.1.1 可靠的实例化过程 当人们说"我写了一个对象来做X事情"时,事实上

《测试驱动数据库开发》——2.2 面向对象编程语言中的类

2.2 面向对象编程语言中的类 测试驱动数据库开发 为何对象的类来到应用开发世界的时间要远远比数据库的类早呢?首先,与在应用开发世界相比,在数据库世界中能让类成为必要元素的影响力没有那么强大,这一点先暂且不谈.其次,相比创建数据库实例,我们能够更加容易地建立可靠的方法来在应用会话中创建对象. 2.2.1 类的构建很容易:构建新对象即可 在面向对象编程的世界中,类其实仅有两个职责:创建新对象和析构(destroy)被废弃的对象.就本书的目的而言,析构其实并不重要.然而,对象的创建绝对是重要的. 在

《测试驱动数据库开发》—第2章2.2节面向对象编程语言中的类

2.2 面向对象编程语言中的类 测试驱动数据库开发 为何对象的类来到应用开发世界的时间要远远比数据库的类早呢?首先,与在应用开发世界相比,在数据库世界中能让类成为必要元素的影响力没有那么强大,这一点先暂且不谈.其次,相比创建数据库实例,我们能够更加容易地建立可靠的方法来在应用会话中创建对象. 2.2.1 类的构建很容易:构建新对象即可 在面向对象编程的世界中,类其实仅有两个职责:创建新对象和析构(destroy)被废弃的对象.就本书的目的而言,析构其实并不重要.然而,对象的创建绝对是重要的. 在

《测试驱动数据库开发》——2.5 实现

2.5 实现 测试驱动数据库开发至此,前面描述的方式能够让读者初步地刻画和实例化数据库的类.下面将介绍一些实现一个数据库的类的方法.本书先从总体需求入手,然后提供一个数据库类的伪代码实现,可以将其移植到任何平台上. 2.5.1 需求 让我们来看看一个良好的数据库的类的实例化机制应该是什么样子的.了解这些需求能够让你编写自己的机制,或者当你面对的需求明显不同于本书描述的情况时,可以调整本书建议的机制,从而适应你的具体情况. 我已经确定了4个需求,并用4个以字母C开头的单词来分别描述之,称其为"4C

《测试驱动数据库开发》——2.4 增量构建

2.4 增量构建 测试驱动数据库开发那么,该如何与上述机制进行交互呢?最好的方式应该是把数据库的每一次变更当做一个单独的版本用文档记录下来,并找到一个好方式(如版本号)来将这些变更进行排序.只要数据库能够标识已经发生了哪些变更,就能构建一个通用的机制来按正确的顺序实施正确的变更. 2.4.1 用文档记录每一次数据库的变更 开始的时候,只编写涉及一个变更的脚本.只要该脚本没有在重要的数据库上运行,就可以根据开发人员的意图,或者根据需求的变化,来随意地修改这个脚本.此时,该脚本其实是在不久的将来要做

《测试驱动数据库开发》—第1章1.2节谁是目标读者

1.2 谁是目标读者测试驱动数据库开发在讨论问题真正的本质是什么和如何解决问题之前,先谈一下关于本书的目标读者.任何读者都可能从本书获取价值,但在使用这本书之前,读者需要具备一些必备的技能. 1.2.1 TDD和OOP为了运用好本书中涉及的技术,读者需要理解测试驱动开发和面向对象编程的好处,但不必是这两方面的专家,只需要知道实现上述两个方面之后所带来的好处是什么.下面这些论断是有意义的. TDD通过让开发者保持在正确的轨道上,以使你能够快速地开发. OOP通过把不相关的事物进行封装并彼此分离,以