2

After a very inspiring training about TDD and BDD, I try to implement the methodology, using MSTest and Specflow. But I have a question where I'm stuck to:

I've written Acceptance Tests to validate a subsystem that we are working on. Our system is a little distributed:

  • there is a 3rd party computer
  • with its own application running freely
  • with a third party database that we are accessing through tcp/ip

However my Specflow Scenario seems too much specialized for my own development set-up: it contains inputs that are valid only for me. In the example below, the ip adress is accessible mostly from me. And the target directory is namely a directory on my machine.

The accredited Tester/Validator, or the Product owner are likely not be able to launch the same test scenario, since they won't have access to this machine. But my developper colleages may not either.

@lastOne
Scenario: Get lattest 3rdParty OCR Data into specified directory
Given I indicate 'database' as the databaseName of third party computer
And I indicate '12.126.42.21' as the ipAddress of the third party computer
And I indicate 'user' as the databaseUser in third party computer
And I indicate 'c:\Temp\test_ocr\' as the destination path where to put the ocr data
And I indicate '2013020800009E' as the truck identifier to be associated with ocr data
When I call the OCR Application program
Then the destination path should contain correctly named xml file, with validated xml data, and jpg files about ocr data.

I am afraid I have some misconceptions about BDD. I am too specific in my scenario ? If yes, where should I stop ?

4

1 回答 1

3

I'm not sure your question is BDD specific but its still a good one.

I would normally recommend that all development is done with a continuous integration server running your tests every time you checkin, even for a private project that you work alone on. Even my own personal projects get this because TeamCity is free and the kids desktop at home is idle when I check in. The importance if this is more obvious if you work in a team, because it stops there ever being any doubt when you get the latest source code that it will build.

But it also stops the problem you have. You can tell very quickly when something is too specific because it doesn't work on both your own personal machine and the build machine. These problems exist whether you work in BDD, TDD, ATDD or any kind of testing.

Looking at your above example, I'd say it is very specific and also very brittle. If the third party PC is switched off one day, all your tests fail. If you were using Specflow to run unit tests then I'd recommend mocking most of your code so you can test without calling the test pc, but your example reads more like you are trying to do system/integration testing.

Instead of specifying all your parameters individually, why not give a name to whole bundle

Given Im using the test pc

you can then set many of them up in the binding and if you need to then tailor them so the tests still pass

[Given]
public void GivenImUsingTheTestPc()
{
  if (Environment.ComputerName == "d1234")
  {
    ipadress = 1.2.3.4;
    ....

This obviously only moves the brittleness but at least it keeps you going for now

于 2013-02-20T11:46:50.157 回答