`
MyEyeOfJava
  • 浏览: 1151393 次
  • 性别: Icon_minigender_1
  • 来自: 北京
博客专栏
7af2d6ca-4fe1-3e9a-be85-3f65f7120bd0
测试开发
浏览量:71152
533896eb-dd7b-3cde-b4d3-cc1ce02c1c14
晨记
浏览量:0
社区版块
存档分类
最新评论

[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
分享到:
评论

相关推荐

    测试驱动开发的艺术Test.Driven.TDD.and.Acceptance.TDD.for.Java.Developers

    - **验收测试**:也称为行为驱动开发(BDD),从用户的角度定义系统的期望行为,通常使用工具如Cucumber进行自动化验收测试。 - **测试金字塔**:提倡更多的单元测试,适量的集成测试,少量的端到端测试,以保持测试...

    Manning.-.JUnit.in.Action.2nd.Edition_英文版PDF

    本书由资深开发人员撰写,详细介绍了如何有效地利用JUnit进行测试驱动开发(TDD)和行为驱动开发(BDD),帮助读者提升代码质量和可维护性。 在Java开发中,单元测试是确保代码质量的重要环节。JUnit作为Java领域最...

    敏捷开发的必要技巧10:验收测试(Acceptance Test)

    验收测试驱动开发(ATDD)和行为驱动开发(BDD)是两种常见的实践,它们强调在开发过程早期编写验收测试,帮助团队理解需求并减少误解。 在实际操作中,验收测试可以通过自动化工具如Cucumber、JBehave或FitNesse来...

    quarkus-testing-showcase:测试展示柜[MIRROR]

    `quarkus-testing-showcase`项目是一个专门用于展示Quarkus测试能力的实例,它包含了多种测试方法和技术,帮助开发者了解如何在Quarkus项目中有效地进行单元测试、集成测试以及行为驱动开发(BDD)测试。 项目中的`...

    Java测试

    FitNesse和Cucumber是两种行为驱动开发(BDD)工具,它们允许非技术人员编写和理解测试用例,促进了开发与业务之间的沟通。 除了以上提到的测试类型,**持续集成和持续部署(CI/CD)**也是现代Java测试的重要部分。...

    企业应用自动化测试实施体系.pptx

    企业应用自动化测试实施体系是现代软件开发中不可或缺的一部分,尤其在敏捷开发环境下,自动化测试能够显著提高测试效率,降低错误率,确保产品质量。本实施体系旨在解决从手工测试向自动化测试转变过程中的挑战,...

    curso_testing_20151102:测试课程

    使用“行为导向测试”的工具 ##链接 静态测试 动态测试 单元测试 时分双工 嘲弄 BDD Cucumber 杰贝夫 网络测试 Selenium http://g00glen00b.be/spring-boot-selenium 压力 http://jmeter.apache.org/ ...

    Automation-Getting-Started:该存储库仅包含针对不同自动化框架的入门项目

    基于屏幕的自动化Sikuli UI Sikuli API单元测试(跑步者) 朱尼特4.12 测试NG 6.6.9整合测试正在汇报引诱宁静(报告使用) 程度Maven单元测试报告Cucumber报告Fitnesse报告BDD CucumberFitnesse 具有魅力的注解网络...

    7 第七章 DevOps工具链.pdf

    - **Cucumber**: 行为驱动开发(BDD)工具。 - **FitNesse**: 面向用户的测试工具。 ##### 2.7 监控工具 - **Nagios**: 网络监控系统,能够监控主机和服务的状态。 - **Zabbix**: 开源网络监控解决方案,支持自动发现...

Global site tag (gtag.js) - Google Analytics