4. Software Quality Assurance (SQA)
● Systematic Monitoring and Evaluation of the
software engineering processes
● Monitoring and Evalution can be done
automatically via tools called QA tools
● Not a Rocket Science, but heavily depends on
the proejct
5. Benefit of SQA?
● early detection of issues
● cleaner & consistent code
● knowledge about the codebase
● increase of confidence
● enables frequent releases, refactoring
7. Manual Testing
● Not automated, slow and expensive
● Complete application must be ready before it
can be tested
● Tests need to be repeated when the application
changes
8. Automated Testing
● Test results are -
– automatically evaluated and
– do not have to be interpreted by a human tester
● Tests are repeatable
– with deterministic results
– without additional costs
9. Selenium Testing
● Test web applications in a web browser
● Selenium RC
– Automated execution of Selenium tests
– Tests can be specified in any language
– One test can be executed on multiple
OS/browser combinations
– Tests can be triggered from PHPUnit
10.
11. problems
● Complex test environments
● Dependencies between tests
● Running the tests is slow, thus incompatible
with the agile approach
● It is not enough and/or does not scale
12. What we want
● We want to test earlier
● We want to be able to test an incomplete
application
● We want a test environment that is less
complex
● We want to be able to run the tests faster
13. Unit Tests
● Executable specification
● Automatic evaluation
● Simple test environment
● Instant feedback
● Works as regression test
>> Unit Tests improve the confidence in your code as they detect problems as early as possible.
14. >> phpunit BowlingGameTest
PHPUnit 3.4.0 by Sebastian Bergmann.
.FFFF
Time: 0 seconds
There were 4 failures:
1) BowlingGameTest::testScoreForAllOnesIs20
Failed asserting that <integer:0> matches expected value <integer:20>.
/home/sb/BowlingGameTest.php:67
2) BowlingGameTest::testScoreForOneSpareAnd3Is16
Failed asserting that <integer:0> matches expected value <integer:16>.
/home/sb/BowlingGameTest.php:75
3) BowlingGameTest::testScoreForOneStrikeAnd3And4Is24
Failed asserting that <integer:0> matches expected value <integer:24>.
/home/sb/BowlingGameTest.php:84
4) BowlingGameTest::testScoreForPerfectGameIs300
Failed asserting that <integer:0> matches expected value <integer:300>.
/home/sb/BowlingGameTest.php:90
FAILURES!
Tests: 5, Assertions: 5, Failures: 4.
17. phploc
● Text-based metric for code size
● Various definitions
– Lines of Code (LOC)
– Comment Lines of Code (CLOC)
– Non-Comment Lines of Code (NCLOC)
– Executable Lines of Code (ELOC)
● Ratios can be interesting
– CLOC / (E)LOC
18. Running phploc on Joomla 1.6.1
Directories: 725
Files: 1625
Lines of Code (LOC): 251967
Cyclomatic Complexity / Lines of Code: 0.12
Comment Lines of Code (CLOC): 88959
NonComment
Lines of Code (NCLOC): 163008
Namespaces: 0
Interfaces: 0
Classes: 1136
Abstract: 81 (7.13%)
Concrete: 1055 (92.87%)
Average Class Length (NCLOC): 126
Methods: 6494
Scope:
NonStatic:
5710 (87.93%)
Static: 784 (12.07%)
Visibility:
Public: 5113 (78.73%)
NonPublic:
1381 (21.27%)
Average Method Length (NCLOC): 22
Cyclomatic Complexity / Number of Methods: 3.44
Anonymous Functions: 10
Functions: 112
Constants: 225
Global constants: 218
Class constants: 7
19. Php code sniffer
● PHP_CodeSniffer
– sniffs for coding standard violations
– ensures code is clean and consistent
– using standard and custom coding standards
● Installation
– pear install PHP_CodeSniffer
20. phpcs on libraries/joomla/application
shyam@ssvlptplnx:/
var/www/j161$ phpcs s
standard=
ZEND report=
summary
sniffs="
Zend.Files.LineLength.LineTooLong" extensions=
php libraries/joomla/application/
PHP CODE SNIFFER REPORT SUMMARY
FILE
ERRORS WARNINGS
/
var/www/j161/libraries/joomla/application/application.php 4 35
/var/www/j161/libraries/joomla/application/categories.php 2 22
......
/var/www/j161/libraries/joomla/application/component/view.php 0 15
/var/www/j161/libraries/joomla/application/pathway.php 0 2
/var/www/j161/libraries/joomla/application/router.php 0 2
A
TOTAL OF 43 ERROR(S) AND 222 WARNING(S) WERE FOUND IN 17 FILE(S)
PHP
CODE SNIFFER VIOLATION SOURCE SUMMARY
SOURCE
COUNT
Zend.
Files.LineLength.LineTooLong 222
Zend.Files.LineLength.MaxLengthExceeded 43
A
TOTAL OF 265 SNIFF VIOLATION(S) WERE FOUND IN 2 SOURCE(S)
24. phpmd on router.php
$>> phpmd libraries/joomla/application/router.php text unusedcode
/var/www/j161/libraries/joomla/application/router.php:247 Avoid unused parameters such as '$uri'.
/var/www/j161/libraries/joomla/application/router.php:255 Avoid unused parameters such as '$uri'.
/var/www/j161/libraries/joomla/application/router.php:263 Avoid unused parameters such as '$uri'.
/var/www/j161/libraries/joomla/application/router.php:270 Avoid unused parameters such as '$uri'.
$>> phpmd libraries/joomla/application/router.php text codesize
/var/www/j161/libraries/joomla/application/router.php:26 This class has too many methods, consider
refactoring it.
$>> phpmd libraries/joomla/application/router.php text naming
$>>
28. Code Coverage
Which statements, branches, and paths are
executed when the tests run?
● Statement Coverage
● Branch Coverage
● Path Coverage
100% Code Coverage is a required, but not a
sufficient criteria for test completeness
29. >> phpunit coveragehtml
/tmp/report BankAccountTest
PHPUnit 3.4.0 by Sebastian Bergmann.
.....
Time: 0 seconds
OK (5 tests, 5 assertions)
Generating code coverage report, this may take a moment.
30. Profiling
● Xdebug's built-in profiler
● Finds bottlenecks in your script
● Output can be visualized by external tools such
as KCacheGrind or WinCacheGrind.
36. Cruise control
Framework for a continuous build process
● Includes, but is not limited to, plugins for email
notification, Apache Ant, Phing, and various
source control tools
● A web interface is provided to view the details
of the current and previous builds