Skip to main content
65 votes
Accepted

How do I really write tests without mocking/stubbing?

This answer consists of two separate views on the same issue, as this isn't a "right vs wrong" scenario, but rather a broad spectrum where you can approach it the way it's most appropriate ...
Flater's user avatar
  • 52.7k
39 votes

Is it a good idea to write all possible test cases after transforming the team to TDD to achieve a full coverage?

There was no test-driven development process during the development due to very tight deadlines This statement is very concerning. Not because it means you developed without TDD or because you aren't ...
candied_orange's user avatar
24 votes

Is it a good idea to write all possible test cases after transforming the team to TDD to achieve a full coverage?

Is it still okay or good idea to stop most of the development and start writing whole possible test cases from the beginning [...] ? Given legacy1 code, write unit tests in these situations: when ...
Nick Alexeev's user avatar
  • 2,512
24 votes

How do I really write tests without mocking/stubbing?

How do I really write tests without mocking/stubbing? You design your code such that it can be tested without mocking and stubbing. That's one of the important, if perhaps subtle, ideas behind TDD: ...
VoiceOfUnreason's user avatar
20 votes
Accepted

Do test-driven and behavior-driven development belong to the "verification" category?

Is it a valid generalization to say that TDD and BDD are classified as "verification"? No. TDD and BDD incorporate verification procedures into the development process in a specific way, ...
John Bollinger's user avatar
18 votes

Does BDD and DDD work well together?

Like @robert-harvey already pointed out, the ubiquitous language is ideally the common binding force. DDD focuses on defining the vocabulary in that language: actors, entities, operations, ... An ...
Ville Oikarinen's user avatar
17 votes

How do I really write tests without mocking/stubbing?

I'm self-proclaimed classicist myself, so let me clear things up a little. First, the unit vs. integration tests. For me, 'unit' test is one that is independent of other tests and doesn't require any ...
Euphoric's user avatar
  • 37.5k
14 votes

What levels to test on with BDD/Cucumber?

If you can answer the question, "Can you give me an example of how X should behave?" then you can do BDD. So, if you want to do BDD at a unit level, think of some examples of how that class or unit ...
Lunivore's user avatar
  • 4,242
14 votes

Do test-driven and behavior-driven development belong to the "verification" category?

Is it a valid generalization to say that TDD and BDD are classified as "verification"? Yes. All testing techniques that take the customers specification as input (and therefor as the truth) ...
Bart van Ingen Schenau's user avatar
12 votes

Differences between Given When Then (GWT) and Arrange Act Assert (AAA)?

There is no difference at all. Three states of test: Given = Arrange, When = Act, Then = Assert. Differences you provided in the question is differences between TDD and BDD and not GWT and AAA. In ...
Fabio's user avatar
  • 3,136
12 votes

Is it a good idea to write all possible test cases after transforming the team to TDD to achieve a full coverage?

In my experience, tests do not need total coverage to be helpful. Instead, you start reaping different kinds of benefits as coverage increases: more than 30% coverage (aka a couple of integration ...
amon's user avatar
  • 135k
12 votes
Accepted

Should you define acceptance tests for vital yet simple behavior?

Yes, test the vital but simple behavior. At least for 3 reasons: The whole idea behind BDD is to promote collaboration between business and technical people, to achieve a common understanding, and ...
Christophe's user avatar
  • 78.6k
10 votes

How do I really write tests without mocking/stubbing?

Let's get rid of labels such as mocks and stubs for a moment, and focus purely on the TDD process. You're starting to write the first test for UserService (I'm going to use your own example): If ...
casablanca's user avatar
  • 4,964
9 votes
Accepted

How can Behavior-Driven Development be a form of Testing-Driven Development/Unit Testing?

TDD was invented by people who focused on behavior. Those people saw it take off and become popular. Once it was popular, it got into the hands of people who thought about TDD structurally. The TDD ...
candied_orange's user avatar
8 votes
Accepted

How does Behavior Driven Development improves clarity when natural languages are ambiguous?

You are correct. BDD does not eliminate problems with language ambiguity - not at all. As others pointed out, the snippets that get translated need to be matched by properly defining them, but this ...
Frank's user avatar
  • 14.4k
8 votes

How to do BDD for CRUD?

I built a mini CRUD application and I would like for someone to complete it by adding the tests If you are doing BDD you should have defined the required behaviour first. then written the tests, ...
Ewan's user avatar
  • 77.4k
8 votes

Should you define acceptance tests for vital yet simple behavior?

One reason I don't use BDD on the regular is that the devil is in the details, and BDD hides detail rather than exposing it. For example, your last line is Then its new position should be the sum of ...
l0b0's user avatar
  • 11.5k
7 votes
Accepted

What advantages are there to using a BDD test tool like SpecFlow over simple unit test tools like MSTest?

The term "BDD" was coined by some TDD practitioners to solve a specific problem: when teaching TDD, the most important hurdle to overcome, is to understand that TDD is not about testing. Dan North ...
Jörg W Mittag's user avatar
7 votes

How to do BDD for CRUD?

Requirements Typically you will define the behavior before you write the code. These start out as somewhat vague high-level requirements: unregistered users should be able to register registered ...
Bryan Oakley's user avatar
  • 25.3k
6 votes

What advantages are there to using a BDD test tool like SpecFlow over simple unit test tools like MSTest?

The first thing to know is the the person that coined the BDD term (Dan North) doesn't use such tools. He uses standard unit test tools. The supposed advantage is the easiness to transform structured ...
Miyamoto Akira's user avatar
6 votes

Functional programming, Domain Driven Design, and Test/Behavior Driven Development

TDD proponents say no design is necessary ... No, TDD proponents say allowing for tests in your design can only improve your design. They don't say you have an awesome design just because it's a ...
candied_orange's user avatar
6 votes

How to do BDD for CRUD?

I believe you have two separate questions here. One is: how can BDD be applied to a CRUD app, and the second is: how can I use BDD to build a simple registration app. BDD does not lend itself to ...
Jon Acker's user avatar
6 votes

How to convert from TDD scripts to BDD?

In practice, you canĀ“t, because the concepts of TDD and BDD are different. Although both test behavior, when you use TDD you create low-level testing to ensure your methods/function is working as ...
Edu Costa's user avatar
  • 330
6 votes

Do test-driven and behavior-driven development belong to the "verification" category?

Tests are a verification activity: they demonstrate that the software system exhibits certain behaviour. However, the act of creating test cases can sometimes have validation-like aspects. TDD and BDD ...
amon's user avatar
  • 135k
5 votes

Testing a private method in Java

I'm having a hard time understanding exactly what it is that you're asking but it seems like your question is more to do with removing the usage of an actual HTTP request than anything to do with ...
Sean Burton's user avatar
5 votes
Accepted

Does BDD/TDD imply an automatable client?

tests that express a scenario need to have control over the client Tests are a client. There is no "the client". A client that uses a service relies on that service exhibiting a certain behavior. A ...
candied_orange's user avatar
5 votes
Accepted

Functional programming, Domain Driven Design, and Test/Behavior Driven Development

First, some clarifications, since you expressed interest in checking your understanding: Functional Programming (FP) Functional programming is a paradigm in which the primary unit of program ...
evocatus's user avatar
5 votes
Accepted

Test RESTful APIs?

Testing the status could be a good sanity check, but you should be testing the response to ensure correctness. If the request/response changes then its tests must also change, In the same way when a ...
Veneet Reddy's user avatar
5 votes
Accepted

How can I unit test this code

The simple answer is probably "you can't unit test this code". You say yourself that the functions are too long and that they're doing multiple tasks. Therefore you have two choices: Don't write unit ...
Philip Kendall's user avatar
5 votes

Is it a good idea to write all possible test cases after transforming the team to TDD to achieve a full coverage?

Don't write tests for existing code. It's not worth it. What you made is already somewhat tested in a completely informal way -- you tried it out by hand constantly, people did some nonautomated ...
RemcoGerlich's user avatar
  • 3,320

Only top scored, non community-wiki answers of a minimum length are eligible