2. Content
•
•
•
•
•
•
•
•
•
Our Problem In Existing System
TDD
Testing with MVC
PHPUnit
PHPUnit Terms
PHPUnit Test-Case Template
WebDriver
Best Practices
How To Install
3. Our Problem In Existing System
Dependency
+
Maintenance
•
•
•
•
Suite Dependency.
Code-maintenance.
Testing on same Joomla-kit.
Tightly-coupled and mix up testing.
6. PHPUnit
Unit Test :
•
•
•
Unit testing simply verify that individual units of code work as expected.
Try to make Robust Extension.
White-box testing
Selenium/WebDriver :
•
•
•
Not unit Test case
Focus only Acceptance-Testing (Validation+Verification) and UX
Black-box testing
PHPUnit
•
•
•
•
•
Testing Framework => Unit + Integration Testing
Reports of Code-coverage (in different formats like HTML , JSON,XML format etc)
Supported DB - MySql(i), Sqlite, PostgreSql, Oracle.
Known what breaks early on and Enforces code quality.
Benefits = Automation + confidence
9. PHPUnit Terms
Stub
•
•
Stub is simple fake object. It just makes sure test runs smoothly.
Test can’t fail.
Mock
•
•
Mock is smarter stub. You verify Your test passes through it.
Test can fail.
SPY
•
You can call object in imitation on, and after you can assert how many times it called.
Fixtures
•
•
•
•
is a “known state” for testing application.
“set up” at the start of test.
“tear down” at the end of the test.
Shares this “states” over test methods.
11. PHPUnit command-line tool prints one character to indicate progress:
•
•
•
•
•
.(Dot) – Printed when a test succeeds.
I – Printed when the test is marked as being incomplete.
S – Printed when the test has been skipped.
F – Printed when an assertion fails.
E – Printed when an error occurs while running the test.
13. WebDriver
•
WebDriver – to control the browser
o WebDriver driver = new FirefoxDriver();
•
•
•
•
•
•
WebElement – to work with the elements on the page
IE, Firefox, Chrome, Safari, Opera etc
Windows, Linux, Solaris and other OS’s
Need to create own webdriver for each test environment
Events generated are the same as for manual testing
WebDriver.TargetLocator switchTo() – switching between the popup-E, alert, windows
WebDriver-Flow
15. Best Practices
•
•
Every behaviour should be covered by one test.
•
•
Mock external states and services.
•
•
•
Test class name have suffix “Test” like ClassNameTest
Test one unit at a Time (follow DRY Principle)(This should force you write non-overlapping code,
break all logic into units).
Should be independent each Test-Case(test-method). But Must be independent each TestSuites(Test-class).
File name should be strtolower(ClassNameTest)
The tests are public methods and The have prefix “test” like testMethod. (You can use
annotation @test)