DEV Community

loading...

Discussion on: Learn Test-Driven Development with Integration Tests in .NET 5.0

Collapse
arjavdave profile image
Arjav Dave Author

That's the beauty of TDD.
In your use case, you will create an empty function CheckValidUser().
Then you write the tests and see them fail.
And finally write the implementation for CheckValidUser() such that the tests pass.

This avoids writing extra unnecessary code.

Initially it might feel counter intuitive like taking your car in reverse by looking at the mirror and not looking back. But once mastered it is the easier and more convenient way.

Collapse
shaijut profile image
Shaiju T

Ok Got it so you will create an empty function. I was thinking how come anyone test something without creating nothing. 😄

Suppose i am working in a company were they need to ship a product within 3 months. Writing TDD will cost time.

TDD can prevent bugs. But what other value does TDD gives ?

Thread Thread
arjavdave profile image
Arjav Dave Author

TDD provides clarity of requirements. One needs to understand the project or a part of project thoroughly before starting deployment.

For me this is even bigger advantage than preventing bugs.

I have seen a lot of developers of dive code first and then think about the architecture, refactoring etc. By the time it's too late.

Thread Thread
jayjeckel profile image
Jay Jeckel

Clarity of requirements should be provided by the specification and design documents, not by code, not even by test code.

Thread Thread
arjavdave profile image
Arjav Dave Author

Agreed. But I was talking more from a standpoint of a developer. He/she needs to be clear on what is to be developed and TDD helps to get this clarity.

The specification and requirements have their own unique place.

Forem Open with the Forem app