CrazyEngineers
  • I've been investing significant time in learning the test-driven development approach for my upcoming projects ( for CrazyEngineers IO ) and frankly speaking, I'm on the edge. On one side, I see the immense benefits of TDD. If you break something, you get to know about the bug right away and can fix it. Of course, it doesn't entirely replace the need of dedicated software testing effort; but you can definitely take care of several stupid mistakes that all developers do.

    But on the other hand, what's putting me back is the amount of time and efforts involved in writing tests. Frameworks solve that to some extent; but on a small project that I recently did, I found out that I was struggling more to write a valid test case than actually writing the code to 'pass' the test.

    I'm curious to know how many of our fellow engineers here do the TDD in their real-world projects. How does it help and what's your argument in favour or against it?
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Ramani Aswath

    MemberSep 22, 2017

    I am grateful to pass on this. Latin is simpler.
    Are you sure? This action cannot be undone.
    Cancel
  • Anoop Kumar

    MemberSep 25, 2017

    First, developers can/should not ran away from unit testing it gives confidence to business that code is tested with proof.

    "TDD is writing unit tests to fail and the code.". Every top gun come and say this. This is awesome and whats wrong with it.
    But, in real time how you write test cases??
    To write test, you need to have concrete interface and method defined, messages defined and complete picture of implementation.Which mean you should have complete design ready no change in this.
    If above is not clear, there will be too many turn around to fix code and then fix tests. Over the top, they say, be agile, requirement can change any time.
    In agile design and requirement is not 100% clear how can you be sure that actual coding is already done in head of developer before starting development.
    Problem with TDD is too much of time wasting and speculating on paper to thing about test cases and loops of code and test.

    In my opinion, following is more efficient manner for coding (before sending code to testing team) -

    Code rough Adhoc Test (manual Test) verify business requirement ⟺ Refine the code Complete ad-hoc manual unit test Write unit tests (rough) cover code as much as possible Send to Testing team for coding and writing acceptance test.
    I would even advocate to just go for rough test and send the code to testing team. In real scenarios testing team can't write their test (Acceptance test) without having code. So while they start writing tests developer can complete the unit tests.
    Are you sure? This action cannot be undone.
    Cancel
  • Kaustubh Katdare

    AdministratorSep 27, 2017

    Anoop Kumar
    To write test, you need to have concrete interface and method defined, messages defined and complete picture of implementation.Which mean you should have complete design ready no change in this.
    This is true and while I'm taking my first steps into TDD, I'm finding it time consuming, yet helpful. If you are a solo developer working on a project, then you've know what the application will look like and function. This design phase is often the hardest part. My strategy is to first draw rough sketches of the interface and then figure out how the user will feel. We did lot of mistakes when launching the first version of crazyengineers.io but have improved significantly in the recent days.

    Where TDD really shines is when you're writing functionality the either derives from or depends upon the existing functionality. I've just written some part of the new project I'm working on and found out that the tests tell me what's breaking. With phpUnit, it's damn easy to figure out which part of the code needs a fix.

    However I've also found myself struggling to get the test to function as expected. I'm still learning; but have lost about 80% of the time trying to get the test to work and writing the relevant application code was only 20% of overall efforts.

    I'm wondering how'd it work when the scope of project grows and you've to modify the tests. Will keep sharing my experience here and look forward to hearing our fellow developer experiences.
    Are you sure? This action cannot be undone.
    Cancel
  • kunaljd

    MemberSep 27, 2017

    unit test cases writing is really important for TDD. Mostly it is used for API based development where Rest /SOAP call are made. are you writing webservices call?
    Are you sure? This action cannot be undone.
    Cancel
  • Kaustubh Katdare

    AdministratorSep 27, 2017

    kunaljd
    are you writing webservices call?
    The web app produces JSON responses; but it's just a minor functionality of the overall app. I'm writing unit tests as well as functional tests; with extra focus on functional tests.

    It's just that the overall efforts in writing a correct test sometimes takes 4x the time to write the actual functionality. It could just be me, though. I'm new to programming.
    Are you sure? This action cannot be undone.
    Cancel
  • kunaljd

    MemberSep 27, 2017

    You already became pro at coding when you ask yourself this question. Most developers ask this to themselves, but never write test cases😲😲 and make simple mistakes like e.g. coding 'O' instead of zero 😀😀😀(ME).

    Our imagination about that project gets nice boost when we write test cases though.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register