in 3240 software testing seminar 01 test-driven development · in 3240/ ifi, 2020, page 1 in 3240...
Post on 25-Jun-2020
11 Views
Preview:
TRANSCRIPT
IN 3240/ IFI, 2020, page 1
IN 3240 Software Testing
Seminar 01
Test-Driven Development
IN 3240/ IFI, 2020, page 2
Part 1: Let’s talk
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
IN 3240/ IFI, 2020, page 4
Image: https://blog.hubstaff.com
Why are we really practicing TDD?
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
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#?
IN 3240/ IFI, 2020, page 7
Part 2: Let’s read
IN 3240/ IFI, 2020, page 8
What is this test about? What is the production code supposed to do?
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
IN 3240/ IFI, 2020, page 10
IN 3240/ IFI, 2020, page 11
Part 3: Let’s practice
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.
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
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
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.
top related