Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Poznan TDD Workshop Part 1

Poznan TDD Workshop Part 1

Pawel Dudek

June 18, 2016
Tweet

More Decks by Pawel Dudek

Other Decks in Programming

Transcript

  1. @eldudi #TDDPoznań “Unit testing is a method by which individual

    units of source code, sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures are tested to determine if they are fit for use.” 4 Kolawa, Adam; Huizinga, Dorota (2007). Automated Defect Prevention: Best Practices in Software Management.
  2. @eldudi #TDDPoznań “Unit testing is a method by which individual

    units of source code, sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures are tested to determine if they are fit for use.” 6 Kolawa, Adam; Huizinga, Dorota (2007). Automated Defect Prevention: Best Practices in Software Management.
  3. @eldudi #TDDPoznan An app is a set of behaviours created

    by programmer and expected by user. 8
  4. @eldudi #TDDPoznań A test is not a unit test if…

    • It talks to a database • It communicates across network • It touches the file system • You have to do special things to your environment to run it (edit config files etc) 25
  5. @eldudi #TDDPoznań A test is not a unit test if…

    • It talks to a database • It communicates across network • It touches the file system • You have to do special things to your environment to run it (edit config files etc) 26
  6. @eldudi #TDDPoznań A test is not a unit test if…

    • It talks to a database • It communicates across network • It touches the file system • You have to do special things to your environment to run it (edit config files etc) 27
  7. @eldudi #TDDPoznan TDD is a great way to determine how

    complex your code has become. You just have to listen. 35
  8. @eldudi #TDDPoznan This always points to an overcomplicated design. And

    your tests are here to point that out. Very clearly. 40
  9. @eldudi #TDDPoznan By writing the test first, you're forced into

    thinking what responsibilities given object should have. 41
  10. @eldudi #TDDPoznan Are unit tests an invaluable tool for writing

    great software? Heck yes.  Am I going to produce a poor product if I can’t unit test? Hell no. Jonathan Rasmusson 48 http://agilewarrior.wordpress.com/2012/10/06/its-not-about-the-unit-tests/
  11. @eldudi #TDDPoznań Good habits 59 • Work outside-in • Use

    examples to clarify requirements • Use ubiquitous language
  12. @eldudi #TDDPoznań Focusing tests fdescribe("Example specs on NSString") { fit("lowercaseString

    returns a new string with everything in lower case") { fcontext("init with damping") { 67
  13. @eldudi #TDDPoznań x’ing tests xdescribe("Example specs on NSString") { xit("lowercaseString

    returns a new string with everything in lower case") { xcontext("init with damping") { 71
  14. @eldudi #TDDPoznań (…) -[SpecSuiteName passing_spec_name] Test Case '-[SpecSuiteName passing_spec_name]' started.

    Test Case '-[SpecSuiteName passing_spec_name]' passed (0.271 seconds). -[SpecSuiteName failling_spec_name] Test Case '-[SpecSuiteName failling_spec_name]' started. Test Case '-[SpecSuiteName failling_spec_name]' failed (0.002 seconds). (…) Executed 2 tests, with 1 failure (1 unexpected) in 0.273 (0.278) seconds 2 tests; 0 skipped; 1 failure; 1 exception; 0 pending 75
  15. @eldudi #TDDPoznań (…) -[SpecSuiteName passing_spec_name] Test Case '-[SpecSuiteName passing_spec_name]' started.

    Test Case '-[SpecSuiteName passing_spec_name]' passed (0.271 seconds). -[SpecSuiteName failling_spec_name] Test Case '-[SpecSuiteName failling_spec_name]' started. Test Case '-[SpecSuiteName failling_spec_name]' failed (0.002 seconds). (…) Executed 2 tests, with 1 failure (1 unexpected) in 0.273 (0.278) seconds 2 tests; 0 skipped; 1 failure; 1 exception; 0 pending 76
  16. @eldudi #TDDPoznań (…) -[SpecSuiteName passing_spec_name] Test Case '-[SpecSuiteName passing_spec_name]' started.

    Test Case '-[SpecSuiteName passing_spec_name]' passed (0.271 seconds). -[SpecSuiteName failling_spec_name] Test Case '-[SpecSuiteName failling_spec_name]' started. Test Case '-[SpecSuiteName failling_spec_name]' failed (0.002 seconds). (…) Executed 2 tests, with 1 failure (1 unexpected) in 0.273 (0.278) seconds 2 tests; 0 skipped; 1 failure; 1 exception; 0 pending 77
  17. @eldudi #TDDPoznań (…) -[SpecSuiteName passing_spec_name] Test Case '-[SpecSuiteName passing_spec_name]' started.

    Test Case '-[SpecSuiteName passing_spec_name]' passed (0.271 seconds). -[SpecSuiteName failling_spec_name] Test Case '-[SpecSuiteName failling_spec_name]' started. Test Case '-[SpecSuiteName failling_spec_name]' failed (0.002 seconds). (…) Executed 2 tests, with 1 failure (1 unexpected) in 0.273 (0.278) seconds 2 tests; 0 skipped; 1 failure; 1 exception; 0 pending 78
  18. @eldudi #TDDPoznań (…) -[SpecSuiteName passing_spec_name] Test Case '-[SpecSuiteName passing_spec_name]' started.

    Test Case '-[SpecSuiteName passing_spec_name]' passed (0.271 seconds). -[SpecSuiteName failling_spec_name] Test Case '-[SpecSuiteName failling_spec_name]' started. Test Case '-[SpecSuiteName failling_spec_name]' failed (0.002 seconds). (…) Executed 2 tests, with 1 failure (1 unexpected) in 0.273 (0.278) seconds 2 tests; 0 skipped; 1 failure; 1 exception; 0 pending 79
  19. @eldudi #TDDPoznań (…) -[SpecSuiteName passing_spec_name] Test Case '-[SpecSuiteName passing_spec_name]' started.

    Test Case '-[SpecSuiteName passing_spec_name]' passed (0.271 seconds). -[SpecSuiteName failling_spec_name] Test Case '-[SpecSuiteName failling_spec_name]' started. Test Case '-[SpecSuiteName failling_spec_name]' failed (0.002 seconds). (…) Executed 2 tests, with 1 failure (1 unexpected) in 0.273 (0.278) seconds 2 tests; 0 skipped; 1 failure; 1 exception; 0 pending 84