DEV Community

Discussion on: How to implement test driven development in the real world?

 
sargalias profile image
Spyros Argalias • Edited

Okay fair enough. Yeah I guess the example you gave didn't really have functionality, it was more of an object which just holds properties.

You're right that we need to test an isolated feature. However what is an isolated feature? It's subjective. For an object with getters and setters, I would argue that an isolated feature is a single property you can set and get. But someone could argue that the object can't be used until everything has been set properly. In that case the test would require setting everything, as you say.

So in the end it depends. If we don't need to set everything at once, then perhaps it would be easier to have one test where we only check the age getter and setter, and another test for the name, and so on... But of course it's up to requirements and personal preference.

Not compiling is acceptable when we do TDD, it's just something we have to work with.

Edit: For the CI/CD pipeline, we don't have to commit until both a test and implementation are working.

I'm repeating myself here but TDD is optional. If it doesn't work for your workflow or preference that's fine. Sometimes I can't use it either. Sometimes I just build and refactor later.

Thread Thread
 
slavius profile image
Slavius

My issue with not compiling is that it breaks my CI/CD pipeline. I'd like to create tests in my test project and the whole solution just compiles but the tests fail. This way my Jenkins/Bamboo/whatever can produce meaningful message to the developers in form of a failed test report instead of a bunch of compiler errors hidden in tons of output.

Thanks for discussion I realized some thinks I was not aware of. ;)

Thread Thread
 
sargalias profile image
Spyros Argalias

*I added a quick edit above about the CI/CD issue.