2

I am looking into TDD and I don't fully understand the approach. I am a web developer using PHP and I can't find any examples of TDD which I can relate to.

So far this is what I understand of ATDD:

User Story

As a customer I want to log into my account so that I can view my account details

Acceptance Criteria

  1. A customer can log in with email address and password
  2. A customer can view their account details

Acceptance Tests

ATTD

(Obviously there will be alot more acceptance tests but this is just extract). 90% of the tests will be automated to help with regression testing in the future

If the above is correct I can't relate what types of tests I would do in TDD. Could someone give me examples of the types of test I would do?

1

You would do:

  • Unit tests for the individual functions you write
  • Integrated tests to make sure dependencies work
  • Acceptance tests for the UI Features
  • Exploratory testing manually
  • Its the unit test part that I don't fully understand. Perhaps using my scenario above could you suggest some unit tests? The functions I would have in my scenario would be login and my account but not sure what I would actually be testing for – user3305256 Dec 5 '16 at 11:45
1

This idea about TDD is that you start with a single test and start building code from there to furfill the test.

You have a couple of levels of test, as described in the test-pyramid, you can start with a UI (end-2-end) level test and then this should result in Service and Unit level tests.

In your case the Acceptance criteria are the UI level tests, but you do not keep them in an Excel-sheet, but they should be executable tests by code. For example with Fitnesse or Cucumber.

Full TDD cycle:

The whole TDD flow is a bit bigger, as described in this video Test-Driven Development (that’s not what we meant) by Steve Freeman

enter image description here

On the fourth level it starts with "Writing a failing end-to-end test" which is followed up by "Write a failing unit-test". You do not even talk about unit-tests in your question.

Also your example start with the login tests, although you might need a login fucntionality this is not a suggested start. Start focusing on feature value and only build a login when you really need it.

Practising TDD:

TDD consists of 4 main skills: Driving development with Tests, Refactoring safely, Designing test cases and Designing Clean code.

To practises skills multiple kata's have been designed, you can start with the StringCalculator kata. Just start with the most simple test you can imaging, something like testing input "" returns 0. The rest should follow from there. The coding dojo handbook has a long list of kata's to practise all TDD skills.

Suggested reads:

  • In terms of TDD I was inferring to unit tests. As my comment above in the other reply I guess my really issue with TDD is with unit tests. I can't get my head around what types of tests I would create for unit tests in my scenario. I understand that the ATTD tests are based on the UI but in my head I am not sure the test contains of the unit tests – user3305256 Dec 5 '16 at 11:59
  • For practising "Driving Developments by Tests" I recommend start with the StringCalculator Kata: osherove.com/tdd-kata-1 – Niels van Reijmersdal Dec 5 '16 at 12:04
  • Thanks and sorry in advance but I still don't fully see how to relate it to my scenario above – user3305256 Dec 5 '16 at 12:55
  • It relates in the follow way: If you have no idea where to start with your unit-tests and what things to test maybe you should practise with small examples that have been designed to learn you how to write unit-tests. TDD is hard, it is about taking small steps in your code, maybe also practise it also by taking small steps and start at the beginning. – Niels van Reijmersdal Dec 5 '16 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.