Date post: | 06-Jul-2015 |
Category: |
Technology |
Upload: | crhym3 |
View: | 1,272 times |
Download: | 1 times |
Software Engineering
●Testing●Unit-testing●JUnit
Why testing at all?
Simplest case: Development => Production
Development Release0
100
200
300
400
500
600
700
Bugs foundBugfix Cost
(random numbers, but you get the idea)
Real world(no testing)
Development Production0
200
400
600
800
1000
1200
1400
1600
435321
€ 200.00
€ 1,500.00
Bugs foundCost per Bug
Real world(no testing)
Development Production0
200
400
600
800
1000
1200
1400
1600
435321
€ 200.00
€ 1,500.00
Bugs foundCost per Bug
435 x 200 = €87,000
321 x 1500 = €481,500
Total:€ 568,500
Real world+ testing+ testing
Development Production0
200
400
600
800
1000
1200
1400
1600
635
121€ 200.00
€ 1,500.00
Bugs foundCost per Bug
635 x 200 = €127,000
121 x 1500 = €181,500 Total:
€ 308,500
no testing vs + testing+ testing
No testing With testing0
100000
200000
300000
400000
500000
600000 € 568,500.00
€ 308,500.00Cost
about a half!about a half!
In the software eng. process...
DesignDesign CodingCoding
ImaginationImagination Real worldReal world
In the software eng. process...
`
GAPGAP
DesignDesign CodingCoding
ImaginationImagination Real worldReal world
In the software eng. process...
TestingTestingDesignDesign CodingCoding
ImaginationImagination Real worldReal world
Continue with examples
A living cell:
A quick introduction to JUnit, D. Steinberg
http://www.slideshare.net/sundar22in/junit
Shopping Cart
Unit testing with JUnit, T. Zimmermann
http://www.slideshare.net/tom.zimmermann/unit-testing-with-junit
Let's try it out!
Create a new Java Project
Let's create a model class ...
... an Ad post
Now, a JUnit Class
Call it PostTest, to follow a name pattern
Confirm to add JUnit library
First things first: setup()setup() and tearDown()tearDown()
Add a couple of methods to our model class
Let's add some tests!
Here we go: Run AsRun As => JUnit TestJUnit Test
All tests passed!
Time for the TestSuiteTestSuite
Let's call it PostTestSuite
Use it with PostTest.classPostTest.class
Let's try it out!
Here you have it:JUnit's Swing GUI
Introducing new model attribute: priceprice
Reflect that in our TestCase and re-run JUnit test ...
Oops! Test failedfailed. Can you figure out why?
Further reading
JUnit FAQ
http://junit.sourceforge.net/doc/faq/faq.htm
JUnit
http://www.junit.org