3. What is unit testing?
A unit test is an automated piece of code
that invokes a unit of work in the system and
then checks a single assumption about the
behavior of that unit of work.
4. What is unit testing?
A unit of work is a single logical functional
use case in the system that can be invoked by
some public interface (in most cases).
A unit of work can span a single method, a
whole class or multiple classes working together
to achieve one single logical purpose that can be
verified.
8. Why we need unit testing?
๏จ Highly stable solution
๏จ Integration of different components will be easier
๏จ New and regression defects can be minimized
๏จ Good unit testing reduces the test cycle for each
phrase
๏จ Good unit testing can be a good reference for the
system documentation
10. Test-Driven Development
๏จ Write test cases for a specific part of your code
๏จ Write your code to โfill inโ the tests. Your code only
serves to make all of your tests pass, and nothing
more
๏จ Once all your tests pass, go back and clean your
code (Refactoring)
TDD gives developers the power to think clearly about
the specifications before they engage themselves with
implementations.
11. Test-Driven Development
Writing a failing test case
Run the test,
Fail?
Write application code
Run the tests,
Success?
Refactor
?
Refactor the code
Yes
Yes
Yes
No
No
No
12. Behavior-Driven Development
๏จ Write application code first.
๏จ Test cases must be small and tests one thing. Test a small
unit of code instead of the entire application
๏จ Run test cases against class or method specific for that
test case
๏จ If test fails, fix the defects and test again
With BDD, you can write specifications that are small and easy
to read.
13. Behavior-Driven Development
Write class(es) or method(s)
Write unit tests
Run the tests,
Fail?
Refactor
?
Refactor the code
No
Yes
No
Yes
Fix the defects
15. What is Jasmine?
Jasmine is a behavior-driven testing
framework for JavaScript programming language.
It does not depend on any other JavaScript
frameworks. It does not require a DOM.