Upload
samad-koushan
View
392
Download
2
Tags:
Embed Size (px)
DESCRIPTION
Introduction to Test Driven Development Software OpenTalks in Tabriz
Citation preview
Software OpenTalks:// . .http tabrizsoftware opentalks co@SamadKoushan
test-Driven
Development
test-Driven
Development
Programming in Real Programming in Real
DeadLine
Error
ErrorWarning
Notice
Warning
WarningWarningNotice
Notice
Notice
Notice
Alpha Version Alpha Version
Alpha Version!!! Who would get off ?
Alpha Version Alpha Version
A group of ten top software engineers is sent to a class for aspiring managers. The teacher walks in and asks this question:
"You work for a software company which develops avionics (software that controls the instruments of an airplane). One day you are taking a business trip. As you get on the plane you see a plaque that says this plane is using a beta of the software your team developed. Who would get off?"
Nine developers raised their hands. The teacher looked at the tenth and asked, "Why would you stay on?"
The tenth said, "if my team wrote the software, the plane would not get off the ground, much less crash."
Automated Testing Automated Testing
This is programming, you should never just hope that your code works properly, you should be able to prove it and prove it again and again, every step of the way, from the very first lines of code you write, all the way through deploying the application.
Automated Testing Automated TestingUncle Bob: The only way to go fast, is to go well.
Automated Testing Automated Testing
TDD is not about how to test software!
We are not talking about:
- beta testing- performance testing- stress testing- integration testing- regression testing- usability testing- ...
Automated Testing Automated Testing
Unit testing: testing we do as programmers not as end-users. We are testing the code itself. Not just the results we may get from clicking button on a user interface.This is about us, testing the individual units of our code, smallest logical piece as possible.We are proving that single class, works the way that class supposed to.
If we passing these particular values into that particular method, we will get this specific result back, and then we go ahead and prove that this is true.
Automated Testing Automated Testing
Automated vs manual testing
Extra Bonus: modifyingHaving automated unit tests allow us to easily validate that any changes we made one place, tomorrow or six month later, doesn't break something that we did earlier.
We will write code that tests our application code, so we have our application code and saved right along side, our simple repeatable testing code.
TDDvsUnit Testing TDDvsUnit Testing
It is not Programming unit test
It is Test Driven Development
Unit test: Wrtie code → write test
TDD: Wrtie test → write code
QAQA
Does TDD Work for everything? - NO
- multi threading- security options- UI testing- Game development
Best practice : 90% or 80% Code Coverage
QAQAAm I supposed to write all my tests first?
9:00:00 AM Write a test9:00:20 AM see test fails9:00:30 AM start writing code to just pass the test
QAQAWe have testers, do they write these tests?
You are coding so you have to write unit tests yourself
QAQATDD does not fix every issues! -That's right!
-Gives you confidence
-Gives you documentation
-Free you from The Debugger
TDDTDD
HOWHOWWriting our test class?
FrameworkFramework
SUnitSmallTalk
JunitJava
PHPUnitPHP
Nunit.NET
PyUnitPython
CppUnitC++
….ETC
Xunit Frameworks
AssertAssertI assert that the earth moves around the sun
- Not asking a question- Not a IF- Not Opinion
- Stating that something be true- Can be positive or negative
- Not replacing exception handler or error messages
- One logical Assertion per test- Each test should have only one reason to fail
AssertAssert
simpleTestsimpleTestWrite a test
simpleTestsimpleTestWrite a test and Watch it fails
simpleTestsimpleTestWrite a code and run test again
simpleTestsimpleTestrefactor
TDDTDD
TDDTDD
AAAAAA
AAAAAA
Testing for Expected Exceptions Testing for Expected Exceptions
Testing for Expected Exceptions Testing for Expected Exceptions
Testing for Expected Exceptions Testing for Expected Exceptions
SettingUp and TearingDown SettingUp and TearingDown
SettingUp and TearingDown SettingUp and TearingDown
SettingUp and TearingDown SettingUp and TearingDown
SettingUp and TearingDown SettingUp and TearingDown
QAQA
Do I test getters and setters?
Do I test private methods?
Can I combine multiple test classes?Test Suites
How do I control the order of tests?You cannot!
MockObjects MockObjects
MockObjects MockObjects
MockObjects MockObjects
MockObjects MockObjects
MockObjects And FakeObjects MockObjects And FakeObjects
...AndMore ...AndMore
Test-driven Development By ExampleKent BeckAddison Wesley
Refactoring: Improving the Design of Existing CodeMartin Fowler , Kent Beck , ...Addison Wesley
Growing Object-Oriented Software, Guided by TestsSteve FreemanAddison Wesley