![Page 1: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/1.jpg)
IN 3240/ IFI, 2020, page 1
IN 3240 Software Testing
Seminar 01
Test-Driven Development
![Page 2: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/2.jpg)
IN 3240/ IFI, 2020, page 2
Part 1: Let’s talk
![Page 3: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/3.jpg)
IN 3240/ IFI, 2020, page 3
TDD:
- What is your understanding of it?
- Where did you hear about it?
- How do you see its use?
- Have you searched on th internet for learning sources?
- What others say about TDD: https://www.youtube.com/watch?v=a6oP24CSdUg
![Page 4: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/4.jpg)
IN 3240/ IFI, 2020, page 4
Image: https://blog.hubstaff.com
Why are we really practicing TDD?
![Page 5: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/5.jpg)
IN 3240/ IFI, 2020, page 5
TDD means writing unit tests firstThe principles of unit tests = F.I.R.S.TUnit tests differ from other tests - they must be F.I.R.S.T.
•Fast: No database connections. In memory•Isolatable/Independent: Tests should not depend on each other•Repeatable: Tests must not depend on external factors•Self-Describing: Each test just returns a boolean result for pass or fail. Youshould not output to find out whether it worked or not.•Timely: Write them before the code
![Page 6: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/6.jpg)
IN 3240/ IFI, 2020, page 6
Unit test frameworks- Usually third party products- Simpify the process of unit testing- It is possible to write unit tests without the support of such a framework
(assertion, exception handling)
Have you heard of unit test frameworks for C#?
![Page 7: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/7.jpg)
IN 3240/ IFI, 2020, page 7
Part 2: Let’s read
![Page 8: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/8.jpg)
IN 3240/ IFI, 2020, page 8
What is this test about? What is the production code supposed to do?
![Page 9: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/9.jpg)
IN 3240/ IFI, 2020, page 9
What are these asserts about? What is the production code supposed to do?
Check Stackoverflow for asserts examples:
https://stackoverflow.com/questions/3241105/java-junit-asserttrue-vs-assertfalse
![Page 10: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/10.jpg)
IN 3240/ IFI, 2020, page 10
![Page 11: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/11.jpg)
IN 3240/ IFI, 2020, page 11
Part 3: Let’s practice
![Page 12: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/12.jpg)
IN 3240/ IFI, 2020, page 12
Exercise:
We take two examples from the Code Dojo and try to reproduce theTDD techniques.
You will choose one and work in a group. You will just have to repeatthe training material in the video. We discuss it after 30 minues.
![Page 13: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/13.jpg)
IN 3240/ IFI, 2020, page 13
https://cyber-dojo.org/
Prime factors:Factorize a positive integer number into its prime factors.For example:
2 -> [2]3 -> [3]4 -> [2,2]6 -> [2,3]9 -> [3,3]12 -> [2,2,3]15 -> [3,5]
JavaScript + CucumberVideo to reproduce: https://www.youtube.com/watch?v=9XhlRgCad60&t=208s
aeUCjm
![Page 14: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/14.jpg)
IN 3240/ IFI, 2020, page 14
https://cyber-dojo.org/
Fizz buzz :Write a program that prints the numbers from 1 to 100. But for multiples ofthree print "Fizz" instead of the number and for the multiples of five print"Buzz". For numbers which are multiples of both three and five, print"FizzBuzz".
Sample output:12Fizz4BuzzFizz78FizzBuzz... etc up to 100JavaScript + Jasmine Video to reproduce: https://www.youtube.com/watch?v=UBrhwDBvgOA
LdhYvu
![Page 15: IN 3240 Software Testing Seminar 01 Test-Driven Development · IN 3240/ IFI, 2020, page 1 IN 3240 Software Testing Seminar 01 Test-Driven Development](https://reader030.vdocuments.us/reader030/viewer/2022040216/5f0cdd907e708231d4378442/html5/thumbnails/15.jpg)
IN 3240/ IFI, 2020, page 15
Discuss
What other information did you find on the internet?
Where did you stumble?
How was yout TDD experience so far?
Remember: • these examples are more complex than the unit tests you will have to
write at work. • Use the many sources of training. Start with videos. Then,
stackoverflow.• Two people to follow: Robert Cecil Martin (Uncle Bob); Roy Osherove
– find their webpages and read about TDD. Watch their videos, expecially the ones debating TDD.