All you need know about testing
-
Upload
jorge-barroso -
Category
Software
-
view
310 -
download
1
description
Transcript of All you need know about testing
![Page 1: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/1.jpg)
Something You Always Wanted to Know About Testing* *But Were Afraid to Ask
Jorge Juan Barroso Carmona
Android Expert
@flipper83 [email protected]
![Page 2: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/2.jpg)
TESTS
![Page 3: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/3.jpg)
What is Testing?
![Page 4: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/4.jpg)
Checking is confirmation, verification, and validation. By machines.
Testing is exploration, discovery, investigation, and learning. By humans.
versus
![Page 5: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/5.jpg)
Why Testing?
Martin Fowler
![Page 6: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/6.jpg)
!
“ more Functionality more Quickly ”
“ Bad code affect to your Costumer ”
![Page 7: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/7.jpg)
What are Unit Tests?
![Page 8: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/8.jpg)
Black-Box before White-Box
![Page 9: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/9.jpg)
creating tests in an environment where they have some Control over their own
Destiny.
Be careful, sometimes Context is Everything.
![Page 10: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/10.jpg)
more Information in a test than in code. Paranoid?
![Page 11: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/11.jpg)
Don’t create your own Problems.
Turn most unit tests into Assertions.
Don’t test Implementation Details.
![Page 12: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/12.jpg)
“ Si tu Unit test tarda más de 1 segundo, cómprate un pony y no me vendas que eso es un Unit test ”
@Jordi9
![Page 13: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/13.jpg)
Mock or Stub?
![Page 14: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/14.jpg)
Stubs are canned answers to calls.
Mocks are objects pre-programmed with expectations.
![Page 15: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/15.jpg)
Avoid creating methods only for stubs.
![Page 16: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/16.jpg)
A Big dependency of Robolectric and PowerMock is a sign of bad code.
![Page 17: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/17.jpg)
Mock dilema: your test only checks that your mocks works.
![Page 18: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/18.jpg)
What are Integration Tests?
![Page 19: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/19.jpg)
Don’t test all your Layers at the same time Or at least Be aware you are doing it
![Page 20: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/20.jpg)
Duplicated tests.
Write O(n!) tests.
where “n” it’s the number of collaborators
![Page 21: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/21.jpg)
Don’t test the System or External Libraries.
Sometimes is a Good practice to test all your layers.
![Page 22: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/22.jpg)
Why you should use Continuous Integration
![Page 23: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/23.jpg)
The best test is the one that is Never executed.
Increase your Time to develop.
Everyone has the latest executable and can see what’s happening.
![Page 24: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/24.jpg)
“ automated crap is still crap. ”
James O Coplien
![Page 25: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/25.jpg)
How to decide the Test Coverage?
![Page 26: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/26.jpg)
Low level coverage says that the code is badly tested, but you cannot claim the opposite with just high level
coverage
![Page 27: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/27.jpg)
100% coverage is to test all possible code paths. Is TDD here?
Tests are code, we need to maintain them.
![Page 28: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/28.jpg)
Risk-based Testing: prioritize the test over the risk of failure, the importance and the impact of failure.
![Page 29: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/29.jpg)
“ I get paid for code that works, not for tests, so my philosophy is to test as little as possible to
reach a given level of confidence ”
Kent Beck
“ In most businesses, the only tests that have business value are those that are derived from
business requirements. ”
James O Coplien
![Page 30: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/30.jpg)
Recap
![Page 31: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/31.jpg)
Silver bullets do not exist.
![Page 32: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/32.jpg)
The really important thing is to write Faster and better code
![Page 33: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/33.jpg)
And please, expose your Dependencies and write Readable code
![Page 34: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/34.jpg)
your Code is more important that your tests.
![Page 35: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/35.jpg)
“ If you find your testers splitting up functions to support the testing process, you’re destroying your system architecture and code comprehension along
with it. Test at a coarser level of granularity. ”
James O Coplien
![Page 36: All you need know about testing](https://reader033.fdocuments.net/reader033/viewer/2022051207/53fe19108d7f72db2d8b459c/html5/thumbnails/36.jpg)
+ James Bach and michael bolton. checking vs testing (2009 - 2013) + Workflows of Refactoring. martin fowler. (oop 2014) + Why Most Unit Testing is Waste. James O Coplien (2013) + 467 tests, 0 failures, 0 confidence. Katrina Owen (Railsberry 2013) + Mocks Aren't Stubs. martin fowler (2007) + Integrated Tests Are A Scam. J.B. Rainsberger (2013) + Exploratory and Risk Based Testing. Bach, J. Kaner, C. (2004) + Decomposing into modules. D.L. Parnas (1972) + The Art of Unit Testing. Roy Osherove + Test Driven Development: By Example. Kent Beck + UnitTest. Martin fowler 2014 !
References