Automated
Testing
Adam
Short
description:
PMA is a popular
web based database management tool. It usually undergoes new releases, bug
fixes, new feature development and refactoring. Since the PMA production code is
changed frequently and our code is finished by developers from all over the
world, in order to guarantee the production quality, it is very necessary to run
Unit testing on Jenkins (Hudson). Unit Tests have several benefits to us. It
allows us changing code quickly under full testing. By running unit tests, a
developer can identify whether his latest changes to the code base has broken
anything. Unit Tests can also help new developers really understand the design
of the code and it can give our developers visual feedback about which lines are
covered. From PMA CI Page, Currently, the code coverage of PMA is 48%. More code coverage means more guarantee
to production.
Goal:
1.
Increase the code coverage to a
reasonable percentage (80%)
2.
Set up the necessary scripts to automate this.
3.
Help
other developers to set up their unit test cases.
4.
Functional
test case to cover render issue
Location
·
Country
: China
·
Time
Zone : GMT +8:00
Education
Postgraduate
student, institute of Software,
Beijing University of Aeronautics and Astronautics,
China
Email
/ IRC / Jabber
·
adamgsoc2013@gmail.com
Synopsis
Since the PMA
production code is changed frequently and our code is finished by developers
from all over the world, in order to guarantee the production quality, it is
very necessary to run Unit testing on Jenkins (Hudson). Unit Tests have several
benefits to us. It allows us changing code quickly under full testing. By
running unit tests, a developer can identify whether his latest changes to the
code base has broken anything. Unit Tests can also help new developers really
understand the design of the code and it can give our developers visual feedback
about which lines are covered. From PMA CI Page, Currently, the code coverage of
PMA is 48%. More code coverage
means more guarantee to production.
About
this idea, at least two things should be done:
1.
Create more test cases to increase the code-coverage of the test-suite
2.
Set up necessary scripts to automate this.
My
goal of this project is to increase the code coverage to a reasonable percentage
(80%) and help other developers to set up their unit test cases. Besides the two
things above, for the display logic code, we can cover them using Functional
test case. In other word, we can use selenium to check Page element is loaded
correctly, I think this work is as important as Unit test. I will coverage
Functional test when I finish Unit testing target.
Benefit
of Functional testing, we can guarantee phpmyadmin can work well on GradeA
browsers.
1.
Check the page is loaded correctly
2.
Check the page is working well o GradeA browsers.
3.
Check the css/js is working well
Benefits
to the users
With the
automatic testing, developers can make changes quickly and provide users a more
stable and fully tested version of phpMyAdmin.
Benefits to
developers: It helps developers to verify that the code changes are working
fine. Unit Tests can also help new developers really understand the design of
the code and it can give our developers visual feedback about which lines are
covered. Users will always get upon each and every change developers can run the
test suite and verify that the changes are safe to commit. By running the
selenium test cases it can be verified that the basic functionalities are
working fine in PMA. Since a large amount of re-factoring is going on,
and it is very helpful if automated testing is available to make sure nothing
will break while re-factoring.
Project
Details
================
1. Automatic Process===================
I am very
familiar with the CI environment and PHP code coverage, because I succeeded to
finishing a similar project when I was an Intern on Yahoo! last
year. I finished an automatic testing job:
1. Finish PHP UNIT code and Functional
testing code.
2. Commit to GIT will trigger a CI
build.
3. The CI build is done by: selenium +
Firefox+ Xvfb (so that we don’t need display)
4. Output the code coverage
report.
================
2. Code Learning ===================
I have more
thoughts on the Phpmyadmin Automatic testing after reading more
codes.
In the index.php
page, PMA will display all the links for users. The links can be some
types:
1. for server operation:
server_<operation>.php (ig:
server_databases.php)
2. for database operation:
db_<operation>.php (ig: db_events.php )
3. for
table operation: tbl_<operation>..php (ig: tbl_replace.php
)
.................
Workflow:
Take
"server_databases.php" for example. It is used to create or drop
database.
In the
server_databases.php, the file will include:
1. "server_databases.js"
in JS folder, it is for Ajax request to backend.
2.
"display_create_database.lib.php" it is output the page element for
create table, including action tag for Ajax request.
3. When an
user clicks the "create", there will be a Ajax request to
db_create.php
4. In
db_create.php, the SQL is executed and return the execution results to
frontend.
5. The
frontend page uses the Ajax request and refreshes the
page.
That is the
simple process for every user operation.
================
3. Unit testing===================
From our code
view:
1. ROOT
folder: there are files about the display and links
In the index.php
page, PMA will display all the links for users. The links can be some
types:
·
1. for server operation:
server_<operation>.php (ig: server_databases.php)
·
2. for database operation:
db_<operation>.php (ig: db_events.php )
·
3. for
table operation: tbl_<operation>..php (ig: tbl_replace.php
)
These
files are not covered by Unit test, so we can use Selenium with Page element
checking to cover them (Functional case). In other word, we can use selenium to
check if Page element is loaded correctly, I think this work is as important as
Unit test. Other benefits, we can cover phpmyadmin can work well with GradeA
browsers.
·
check
the page is loaded correctly
·
check
the page is working well with
GradeA browsers.
·
check
the css/js is working well
2. For the
Library folder, there is backend logic, it is suitable to use UNIT test to
cover.
·
Create more test cases to increase the code-coverage of the test-suite
·
Set up necessary scripts to automate this.
Automate building process, running unit tests; generate code coverage and
analysis using Jenkins
Deliverables
·
Unit
testing code coverage grows
to a reasonable percentage: 80%
·
With
selenium testing scripts,
help more developers
setup their Unit test case.
·
Functional
test case
·
Increase
some regression testing cases.
Time
About
40 hours per week.
Bio
I
am Adam. Currently I am a student of Institute of Software, Beijing University of Aeronautics and Astronautics,
China. I am quite interested on the topic: Automatic testing. I have some
developing experience on selenium and PHP Code Coverage. I am very familiar with
the CI environment and PHP code coverage, because I succeeded
to
finishing
a similar project which
is automatic testing as well when
I was
an Intern
on Yahoo! last year:
1. Finish PHP UNIT code and Functional
testing code.
2. Commit to GIT will trigger a CI
build.
3. The CI build is done by: selenium +
Firefox+ Xvfb (so that we don’t need display)
4. Output the code coverage
report.
Experiences
·
I
am very familiar with the CI environment and PHP code coverage, complete an
automatic testing project as an internship on Yahoo! Last.
·
Having
strong knowledge of php and experiences
on working
with cakephp frame work.
·
Familiar
with OOP and Design patterns, data structure, and algorithm.
·
Familiar
with Hadoop distributed framework and the Map-Reduce algorithms (have project
experience)
·
Good
knowledge of SQL.
·
Excellent
in web development using PHP, HTML, JavaScript, MySQL
·
Good
knowledge of svn and Git
Open
source contributions
·
https://github.com/adamgsoc2013
phpMyAdmin
contributions
Have merged:
https://github.com/phpmyadmin/phpmyadmin/pull/233 add test case
for PMA_Header_test
https://github.com/phpmyadmin/phpmyadmin/pull/240
Still on review:
https://github.com/phpmyadmin/phpmyadmin/pull/245 add test case
for Table Class
https://github.com/phpmyadmin/phpmyadmin/pull/244 add test case
for PMA_Footer_test.php
https://github.com/phpmyadmin/phpmyadmin/pull/243 add test case
for Config.class.php
Still on working:
https://github.com/phpmyadmin/phpmyadmin/pull/246
Add Class PMA_Navigation_test to cover navigation test