Comments by "" (@ContinuousDelivery) on "BDD Explained (Behaviour Driven Development)" video.
-
Thank you! I think that I have a mostly rational, mostly consistent approach to software development. I think that helps with explaining my ideas, because my view, at least inside my head, is consistent. I believe that I have "strong opinions, lightly held". I am easy to convince that I am wrong, if you have evidence or a stronger theory than mine, but I try to not change my mind based on emotion, rhetoric, or sometimes abuse :)
I think you may overstate my conversational skills, I am good on a few nerdy topics and rubbish at chat :)
32
-
7
-
6
-
4
-
@michaelmorris4515 Well, I disagree with you on most of those points 🙃
The 'so general it is nonesensical' is really just restating what you said, the only value that you mentioned from a user's perpsective - which is what a BDD scenario should be testing, is not which page they are on, but that they can do useful work. Now, technically, in your implementation, to do that useful work, they have to be on a certain page, but surfacing that in your test case is just hard-coding the plumbing.
I don't think that this is "3 lines for the sake of being 3 lines" I think that it is focusing on "What the user cares about" rather than "How the dev team needs to implement" these should be separate things, and that separation is the "What" vs "How" that I talk about. Your example, was still quite a lot about "How", I was trying to move it away from that.
That point is more important than 5 lines vs 3 IMO.
4
-
3
-
3
-
For me the big idea here, for high-level functional tests or low-level unit tests, is to separate what the system (or code) does, from how it does it. BDD style unit tests test that the code does what you want it to do, while, as far as possible, not being tied to how it does it. This means that there is a difference between the external representation of our code, and the code itself. One of the reasons that people struggle is that they don't think enough about this difference, every function signature should hide something of what happens behind it. The test tests the use of the code, not its implementation. The outcome, not the mechanism.
3
-
3
-
2
-
2
-
1. I think that BDD is a broadly applicable idea. Fundamentally it is about using automated tests as specifications rather than as tests. To do this the prime directive of BDD, IMO, is to ensure that our specs only say "what" the system should do, without saying anything about "how" it does it. This works for nearly all automated tests. There are times when BDD isn't enough, but I think it is always applicable. It is not good as the only way to test very graphical systems, you can't really write a behavioural spec for "does it look nice". You can write a spec for "If I shoot the bad guy he explodes" that is a behaviour, but what it looks like when he explodes is not really. So I'd use BDD for pretty much everything, but add other forms of tests for some things.
2. The key is what I said, create specifications from the perspective of an external "user" of the system you are testing. If that "user" is some code, that is fine, it is the outside perspective that is the important point. BDD works fine for VERY technical things. There are only 2 problems, 1) BDD is not the same as tools, so the ideas work everywhere, the tools may not be correct. I probably wouldn't use Gherkin for testing embedded devices. 2) You have to be even more disciplined as a team when dealing what technical things. The language of the problem domain, the language you should express your specs in, is now a technical one, so you must be laser focused on keeping "what" separate from "how". It is now much easier to slip into bad habits and start writing specs from the perspective of you the producers, rather than from a consumer of your system. Always abstract the interactions in your specs. Never write a spec that describes anything about "how" your system works.
2
-
2
-
2
-
2
-
2
-
2
-
2
-
2
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
@michaelmorris4515 I am afraid that none of your assumptions here are true. First, this is not a theoretical approach, I, and many others, have used this on big complex real-world systems. One of my clients used this approach to test medical devices in hospitals. Another uses it to test scientific instruments. I built one of the world's highest-performance financial exchanges using this approach, and I found out this week, that the tests are still working and providing value 13 years later.
I think that your example focuses on the technicalities rather than the behaviour. "I expect the transaction table to show these values" sounds to me like you are leaking implementation detail into your test cases, and that is why they are fragile. What is it that the user really wants? Do they really care about "transaction tables" when they walked up to the computer to do a job, were they thinking "what I need to do is make sure that the transaction table shows these entries"? I doubt it.
I can't give you a real example, because I don't know what your app does, but I'd try an capture the intent that the user had. So forgive me for making something up, but lets say that in your case a "transaction" represents selling something, and your "transaction table" represents a list of things, or services, sold. Then I can think of a few scenarios that matter to a user. "I want to be able to buy something and see that I have bought it" (it ends up in the "transaction table"). "I'd like to be able to buy a few things and see a list of the things that I bought" (they all end up in the transaction table). and so on.
1
-
1
-
1
-
1
-
1
-
1