10. Unit Testing
In computer programming, unit testing is a software
testing method by which individual units of source
code, sets of one or more computer program
modules together with associated control data, usage
procedures, and operating procedures, are tested to
determine whether they are fit for use.
https://en.wikipedia.org/wiki/Unit_testing
11. Functional Testing
Functional testing is a quality assurance (QA) process and a type
of black box testing that bases its test cases on the specifications of
the software component under test. Functions are tested by
feeding them input and examining the output, and internal
program structure is rarely considered (not like in white-box
testing). Functional testing usually describes what the system
does.
Functional testing does not imply that you are testing a function
(method) of your module or class. Functional testing tests a slice
of functionality of the whole system
https://en.wikipedia.org/wiki/Functional_testing
12. Acceptance Testing
In engineering and its various subdisciplines, acceptance testing is
a test conducted to determine if the requirements of a
specification or contract are met.
In software testing the ISTQB defines acceptance as: formal testing
with respect to user needs, requirements, and business processes
conducted to determine whether or not a system satisfies the
acceptance criteria and to enable the user, customers or other
authorized entity to determine whether or not to accept the
system.
Acceptance testing is also known as user acceptance testing (UAT),
end-user testing, operational acceptance testing (OAT) or field
(acceptance) testing.
https://en.wikipedia.org/wiki/Acceptance_testing
13. How I think about types
Unit tests test your functions and methods.
Functional tests test parts of your application.
Acceptance tests test your interactions.
35. How to run tests
codecept run // runs all tests
codecept run functional // run functional tests
codecept run functional tests/functional/
AdminCanLoginCept.php // run single test
Can also add -vv or -vvv for detailed output
37. What are we testing?
The route ‘auth/login’ shows us a login form
Submitting login form performs some action
Dashboard (after successful login) displays
Some success text exists “Hello admin!”
38. What are we NOT testing?
Navigation on the page
“Remember Me” functionality works
Password Reset works
User is actually an admin
46. Test will pass when…
the user exists in the database
the routes (get and post) work as expected
login form view renders properly
dashboard view renders properly
74. Using XPath for form fields
isn’t very easy to read.
XPath isn’t very easy to
read…
75. When to use XPath?
When you can’t add an ID or Class on an element
When you want to ensure styles/formatting
(error messages, flash messages, etc)
When testing navigation elements
When testing any dynamic elements
80. Some issues…
PhantomJS pretty broken on Travis-CI
Acceptance tests are SLOW (and memory hogs)
Acceptance tests aren’t unit tests, it can be hard
to find WHAT is causing the tests to fail
Functional & Acceptance tests aren’t
replacements for unit tests, but can be easier to
write if your app isn’t written to be testable