SlideShare a Scribd company logo
1 of 57
Download to read offline
Agile Testing
BC Holmes
@bcholmesdotorg
© 2015 Intelliware Development Inc.
What you’ll learn in this presentation:
• Why do we use Agile testing?
• What Agile testing isn’t
• What Agile testing is: unit testing and test-driven development (TDD)
• High-level properties of good tests
• Testing in different languages
• Test suites and code coverage
• Using mock objects to help isolate units
• Beyond unit testing
© 2015 Intelliware Development Inc.
Design
• A test usually provides a concrete usage scenario that helps a developer think
about the following when writing code:
• What is the code expected to do?
• How will the code be set up and executed?
• What other pieces of code are needed as collaborators, and how will the code interact
with them?
• Especially good at helping to write code that is loosely coupled.
3© 2015 Intelliware Development Inc.
Why do we use Agile testing?
Why do we use Agile testing?
Focus/Rhythm
• Unit tests provide an easy way for a developer to focus
on a particular coding task.
• Clear and fast feedback if the code is working or not.
• Always clear what to do next:
• Either fix a failing test or write a new test as a prelude to
adding functionality.
4© 2015 Intelliware Development Inc.
What Agile testing isn’t
Agile Testing is not a “phase”.
• In traditional methodologies, testing is a phase of the project that happens after coding.
• In Agile methodologies, coding, refactoring and testing are tightly inter-related tasks and
can’t be separated.
A testing “phase” that’s months, weeks or even days in the future provides
very slow feedback to developers.
• Faster feedback gets failure information to developers while the details of the code
implementation is still fresh in their minds.
5© 2015 Intelliware Development Inc.
What Agile testing isn’t (continued)
Agile testing is not a replacement for quality assurance (QA) testing.
• Agile testing is a practice to help developers create better code.
• Agile testing is intended to improve the quality (design, defects, etc.) of the final code
deliverables.
• That might mean that you have a lower need for QA, but not necessarily.
6
It’s noteworthy that Lisa Crispen’s book, Agile Testing,
is principally about the role of dedicated QA-style
testers on Agile projects, rather than the testing
practices of Agile developers.
© 2015 Intelliware Development Inc.
What Agile testing is:
unit testing and test-driven development
© 2015 Intelliware Development Inc.
Test-driven development (TDD)
TDD is one of the earliest forms of Agile testing, and the most
commonly implemented types of Agile testing. It’s a style of
programming in which three activities are tightly interwoven:
coding, testing (in the form of writing unit tests) and design (in
the form of refactoring).
• Write a "single" unit test describing an aspect of the program.
• Run the test, which should fail because the program lacks that feature.
• Write "just enough" code, the simplest possible, to make the test pass.
• "Refactor" the code until it conforms to the simplicity criteria.
• Repeat, "accumulating" unit tests over time.
8
Source: Agile Alliance
© 2015 Intelliware Development Inc.
Origins
9© 2015 Intelliware Development Inc.
What is a unit test?
“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 if they are fit for use. Intuitively, one can
view a unit as the smallest testable part of an application.
[…] In object-oriented programming, a unit is often an entire
interface, such as a class, but could be an individual method.
Unit tests are short code fragments created by
programmers… during the development process.”
10
Source: Wikipedia
© 2015 Intelliware Development Inc.
The TDD process
11
Commit code
Create a unit
test
Execute the
Test
Fix the code
so that the
test runs
Execute the
Test
Refactor the
code
Run all tests
Automated
build (includes
running tests)
© 2015 Intelliware Development Inc.
Creating a simple unit test in Java
• Unit tests are most
commonly created using the
JUnit framework.
• Imagine this scenario: we’re
writing code to calculate
mortgage payments.
12© 2015 Intelliware Development Inc.
Create code that tests a specific expectation
13© 2015 Intelliware Development Inc.
Run the unit test
• In this example, we’re using Eclipse’s
built-in JUnit test support to run the unit
test.
• The red bar indicates that our test
doesn’t yet pass successfully.
• Note how the test name appears to
clarify which test has failed.
• The name gives an indication of the expected
behaviour.
14© 2015 Intelliware Development Inc.
Fix code and rerun
• The developer should write enough
code to make the test pass.
• The green bar indicates that all the
expected behaviour is correctly
implemented.
15© 2015 Intelliware Development Inc.
Rules about tests
• Often, once the tests are green, the developer’s next step is to
refactor code.
• Refactoring involves improving the design of existing code.
• Make it more readable, increase the efficiency, or remove duplication.
• The tests help to ensure that the developer hasn’t broken any functionality during
the refactoring.
• Run all tests before committing or pushing code in to the source
code repository.
• If there are any broken tests, you should not commit.
• Automated build processes should run all of the tests as an
indication of the validity of the build artifacts.
16© 2015 Intelliware Development Inc.
Some high-level properties of good tests
© 2015 Intelliware Development Inc.
Representative: Of events that are
likely to be encountered by the user.
(Not necessarily “commonly”, but
likely). Hacking attempts, for
example, might be likely, but not
common.
Non-redundant: The test shouldn’t
reproduce the work of another test.
Motivating: Your client will want to
fix the problem exposed by this test.
Properties of good tests
Power: A test should reveal
problems when they exist.
Valid: When the test states that
there’s a problem, it is a genuine
problem.
Value: Tests should reveal problems
that the client cares about.
Credible: The test should be trusted
to actually test the things that people
expect it to test.
18
Source: Cem Kaner
© 2015 Intelliware Development Inc.
Coverage: The test exercises a part
of the code that isn’t already handled
by another test.
Easy to evaluate: It should be
relatively easy to determine whether
the test has passed or failed.
Insightful: A good test should reveal
things about our assumptions.
Properties of good tests (continued)
Performable: Designing a test that
can’t actually be performed is
useless.
Maintainable: If the end product
changes, it’s important to be able to
update the tests.
Repeatable: It should be easy and
inexpensive to execute the test again
and/or reuse it as appropriate.
19
Source: Cem Kaner
© 2015 Intelliware Development Inc.
Cost: the cost to
create/execute/maintain the
test should compare favourably
to the value.
Opportunity Cost: The test
obviates the need to perform
some other work.
Supports troubleshooting: If the
test fails, it should help the
programmer identify the problem.
Appropriately complex: No more
complex than necessary.
Accountable: Can you explain why
the test exists, and can you
demonstrate that it was executed?
20
Source: Cem Kaner
© 2015 Intelliware Development Inc.
Properties of good tests (continued)
Testing in different languages
© 2015 Intelliware Development Inc.
Common unit test frameworks
Java
• JUnit, TestNG.
.Net
• Microsoft Unit Testing Framework and NUnit.
JavaScript
• Mocha, Jasmine, Unit.js, Nodeunit, QUnit, JSUnit, and
many others.
iOS / Objective-C
• XCUnit (successor to OCUnit).
Python
• Nose, unittest (a.k.a. PyUnit).
22© 2015 Intelliware Development Inc.
Unit testing with JavaScript and Mocha.js
Slightly different syntax from JUnit, but most concepts are comparable.
23© 2015 Intelliware Development Inc.
Executing Mocha.js on the command line
Most JavaScript unit test frameworks are command-line-based.
24© 2015 Intelliware Development Inc.
Unit testing with C# and Microsoft’s unit testing tools
Again, slightly different
syntax, but same basic
concepts.
25© 2015 Intelliware Development Inc.
Visual Studio’s built-in test support
26© 2015 Intelliware Development Inc.
Testing with Objective-C and XCUnit
27© 2015 Intelliware Development Inc.
XCode’s built-in support for XCUnit
28© 2015 Intelliware Development Inc.
Successful execution
29© 2015 Intelliware Development Inc.
Key insights
Unit testing in a variety of languages (and test frameworks)
is largely the same.
• Test a specific function and give it a descriptive name.
• Set up some necessary classes and/or data.
• Invoke the function/method under test.
• Check/assert that calculated values match expectations.
Most test runner tools use red and green indicators to tell
developers the current state of the tests.
30© 2015 Intelliware Development Inc.
Test suites and code coverage
© 2015 Intelliware Development Inc.
Test suites
Over time, as more and more tests are created, a sizeable amount of the
application is backed by unit tests that are executed many times a day to
ensure that previously-created functionality still works.
• Hundreds or even thousands of unit tests are not uncommon for a single application.
As more and more tests are added, the amount of time it takes to execute
the tests increases.
• If that amount of time is too long, developers will start becoming discouraged from running
the tests regularly.
• A few seconds is awesome.
• Less than 30 seconds is still pretty good.
• A few minutes isn’t terrible.
• More than that is likely to be irritating.
32© 2015 Intelliware Development Inc.
Code coverage
Some languages/environments have tools that can calculate the amount of
your application’s code that gets executed during the running of the unit test
suite.
• These tools are called “code coverage” or “test coverage” tools.
High coverage usually indicates that the application is well-tested, and that
usually results in developer confidence that they can change the application
and not break the existing functions.
• How high is high enough? There are a lot of factors and not all projects are the same, but
75% or 80% coverage is often used as a starting goal.
33© 2015 Intelliware Development Inc.
Some stuff is hard to test
Visual output
• Does a web page look attractive? Is an animation jerky or glitchy? Is one component of a
web page covering or obscuring another component?
• Graphical output — especially image-based.
• Example: a class that outputs a bar chart as a PNG image.
Code that’s date/time-driven or based on timers
• But if you parameterize the date/time information, you can often mitigate the difficulty.
Legacy code
• The best time to start unit testing code is at the beginning of a project.
• Legacy code, especially tightly-coupled stuff, is harder to make testable.
34© 2015 Intelliware Development Inc.
Using mock objects to help isolate units
© 2015 Intelliware Development Inc.
Mock objects: dealing with collaborators
“In object-oriented programming, mock
objects are simulated objects that mimic
the behaviour of real objects in controlled
ways. A programmer typically creates a mock
object to test the behaviour of some other
object, in much the same way that a car
designer uses a crash test dummy to
simulate the dynamic behaviour of a human
in vehicle impacts.”
36
Source: Wikipedia
© 2015 Intelliware Development Inc.
Tools for working with mock objects
Usually involves a mock framework
• Java
• Mockito, Jmock
• JavaScript
• Sinon.js
• Objective-C
• OCMock
37© 2015 Intelliware Development Inc.
Example
We want to test functionality related to
renewing a mortgage.
• Renewing a mortgage should be based on same
payment type, but current interest rate.
Mortgage collaborates with a class that
provides the current interest rates.
• But we’re currently testing the renew functionality, not
the providing of interest rates.
Let’s try an example using Java and Mockito.
38© 2015 Intelliware Development Inc.
39
Need a special
test runner
© 2015 Intelliware Development Inc.
40© 2015 Intelliware Development Inc.
Additional thoughts
Mock object frameworks provide a powerful way to ensure
that you’re testing only a single unit at a time.
• Helps isolate an individual unit.
If the configuration of your mock object starts to get
complex or messy, that’s an indication that your class is too
tightly intertwined with the mock object’s class.
• Remember: loosely-coupled classes are easier to test, and usually a
better design choice.
41© 2015 Intelliware Development Inc.
Defining your units
A “unit” is often a class or small collection of related classes.
• Anything not contained in that “unit” is a dependency or collaborator.
• We usually create mock objects to take the place of the dependency/collaborator when we
build the unit test.
Consider special case: a class that reads data from a database.
• In Java, such classes are often referred to as “Data Access Objects” or DAOs.
• Key question: does the “unit” that you’re testing include the database?
• Or should the database be considered a dependency/collaborator?
42© 2015 Intelliware Development Inc.
The case for “no”
• Unit tests that connect to the
database are often slower than
most other unit tests.
• Both because of set up and
because of I/O.
• You need to consider the
contents of the database: does
your test expect certain records?
How do they get there? What if
those contents are changed?
Managing the initial state or
“home state” of the database is a
non-trivial exercise.
My gut is telling me “maybe”
The case for “yes”
• It’s often hard to mock out an
entire database API.
• Including the database allows
you to test more: object-
relational mapping
configuration, query
correctness, etc.
• If you use database features
such as triggers or stored
procedures, this might be the
only way you can test those.
43© 2015 Intelliware Development Inc.
Database tests
Don’t get hung up on the name.
• Whether or not they’re “unit” tests, it’s often fruitful to include
tests that touch the real database.
Dealing with “Home State” is often worth the initial
investment.
• Home state is a version of the database (or other resource)
that contains the data that the tests expect.
44© 2015 Intelliware Development Inc.
Approaches to home state
Restore the database prior to running tests.
• Always brings the data back to home state, but might take time.
Have a separate database specifically for unit tests to use.
• But need to apply necessary table definition changes as the project evolves.
Don’t let unit tests change the state of the database.
• Rollback any changes or undo database changes when the tests finish.
• Doesn’t help if the same database is used for ad-hoc testing.
Try to minimize the expectations.
• Not always possible or easy.
Home state management isn’t easy, but the benefits are worth it.
45© 2015 Intelliware Development Inc.
Beyond unit testing
© 2015 Intelliware Development Inc.
Beyond unit testing
Although Agile testing is often described in terms of creating unit tests, there
are other forms of testing that can prove useful for an agile project.
Common test types:
• Integration Tests: tests that integrate a number of units, to ensure that the parts interact
with one another properly.
• UI Tests: tests that automate interaction with a UI and the complete application codebase to
ensure that all parts function together properly.
• Performance Tests: tests that automatically capture information about the response time of
the application, possibly under load.
• Static Analysis Tests: tests that analyze code, looking for violations of coding conventions
and development rules.
• Acceptance Tests: tests that demonstrate to the customer that the requested functionality
has been implemented.
47© 2015 Intelliware Development Inc.
Integration testing
Sometimes, the integration between multiple units is sufficiently
complex that it’s fruitful to test it.
• Especially true of application-specific code that needs to be integrated with and
configured in major frameworks.
Examples:
• Ensure that a certain number of classes are correctly configured and wired
together in a Spring configuration file.
• Ensure that a SOAP interface has been correctly configured to send or receive
the necessary data.
The goal is to integrate no more parts than absolutely necessary.
48© 2015 Intelliware Development Inc.
Integration tests (continued)
Because more parts need to be set up and initialized, integration
tests may take longer than other types of tests.
• Integration tests might end up being run less frequently.
Still interested in this question: “Do the integration tests run quickly
enough that we can expect the developers to run them prior to
synching with source control?”
• A “yes” answer provides more value than a “no” answer, but a “no” answer can
still be helpful.
49© 2015 Intelliware Development Inc.
UI tests
Can be considered a special case of integration tests —
essentially integrating all of the parts.
Examples:
• Web UI Tests.
• Launch the full application in a web server.
• Selenium is a very commonly-used web UI test tool.
• Mobile UI Tests
• There are many approaches to building mobile apps.
• Native, HTML5 or Mobile Application Development Platforms (MADPs)
like Worklight, Kony or Appcelerator Titanium.
• As a result, no one mobile UI test tool has become de facto standard, so
mobile UI testing is still an emerging discipline.
50© 2015 Intelliware Development Inc.
Performance tests
• If one of the requirements (user stories) of your application involves
performance targets, testing is the ideal way to ensure that those targets
are met.
• While Agile developers often caution against premature performance
optimization, it’s also not necessarily a good idea to wait until the end of a
project to test performance.
• Performance testing often tests the integration of many of the parts of the
application, rather than just individual units.
• We frequently instrument applications to gather performance metrics, and
run a suite of performance tests that can give us a performance checkpoint
with every build.
51© 2015 Intelliware Development Inc.
Automated performance test report
Three types of data:
• What’s the current
performance, at the highest
level (see diagram)?
• What’s the current
performance at different
layers of the application
(Service Layer, DAO Layer).
• What the historical
performance?
52© 2015 Intelliware Development Inc.
Static analysis tests
• Developers tend to think of functional business requirements as
the things that drive unit tests.
• Unit tests can additionally be built around non-functional requirements or even
development rules or standards.
• Examples:
• Organization has a web standard to use relative units (e.g.: rems) rather than
pixel units (px) in web page style sheets (CSS).
• Write a unit test that scans all of the CSS and fails if px units are found.
• Architectural standard that Java code should not have cyclical package
dependencies.
• Write a unit test that fails if package cycles are found.
53© 2015 Intelliware Development Inc.
Static analysis tests (continued)
• Provides proactive identification of problems, rather than after-the-fact
need for clean-up.
• Interesting consequence:
• Tests continue to enforce rules as more code or more developers are added to the project.
• Developers can’t say, “nobody told me about that rule!”.
54© 2015 Intelliware Development Inc.
Acceptance tests
• An acceptance test is a description of a scenario that demonstrates the
expected behaviour of a software component.
• Ideally, the acceptance test is recorded in a way that’s readable by a
customer (and developers), but still supports automated execution.
• Several tools such as JBehave or Cucumber, attempt to make acceptance tests readable
while still providing automated execution.
• Acceptance Testing is often tied to the idea of “Behaviour Driven
Development”.
• Emphasizes “specifications” and “scenarios”.
• Many BDD proponents like the “Given-When-Then” structure.
• Given a particular context, when an action is taken, then a particular result is expected.
55© 2015 Intelliware Development Inc.
56© 2015 Intelliware Development Inc.
About Intelliware Development Inc.
Intelliware is a custom software, mobile solutions and product development
company headquartered in Toronto, Canada. Intelliware is a leader in Agile
software development practices which ensure the delivery of timely high quality
solutions for clients. Intelliware is engaged as a technical partner by a wide
range of organizations in sectors that span Financial Services, Healthcare, ICT,
Retail, Manufacturing and Government.
/company/intelliware-development-inc-
/intelliware.inc
/intelliware_inc
/GooglePlusIntelliware
www.intelliware.com
© 2015 Intelliware Development Inc.
Check out other entries in our Agile methodology series
57

More Related Content

What's hot

Effective Testing Practices in an Agile Environment
Effective Testing Practices in an Agile EnvironmentEffective Testing Practices in an Agile Environment
Effective Testing Practices in an Agile EnvironmentRaj Indugula
 
Why Scaling Agile Doesn't Work (and What to Do About It)
Why Scaling Agile Doesn't Work (and What to Do About It)Why Scaling Agile Doesn't Work (and What to Do About It)
Why Scaling Agile Doesn't Work (and What to Do About It)Jez Humble
 
Agile Executive Briefing - Situational Assessment + 50k Ft View
Agile Executive Briefing - Situational Assessment + 50k Ft ViewAgile Executive Briefing - Situational Assessment + 50k Ft View
Agile Executive Briefing - Situational Assessment + 50k Ft ViewMichael Sahota
 
How to measure the outcome of agile transformation
How to measure the outcome of agile transformationHow to measure the outcome of agile transformation
How to measure the outcome of agile transformationRahul Sudame
 
About Agile & PMI Agile Certified Practitioner (PMI-ACP) Overview
About Agile & PMI Agile Certified Practitioner (PMI-ACP) OverviewAbout Agile & PMI Agile Certified Practitioner (PMI-ACP) Overview
About Agile & PMI Agile Certified Practitioner (PMI-ACP) OverviewAleem Khan
 
Building Quality In in SAFe – The Testing Organization’s Perspective
Building Quality In in SAFe – The Testing Organization’s Perspective	  Building Quality In in SAFe – The Testing Organization’s Perspective
Building Quality In in SAFe – The Testing Organization’s Perspective Yuval Yeret
 
Agile101 - What Agile Is and What Agile Is Not
Agile101 - What Agile Is and What Agile Is NotAgile101 - What Agile Is and What Agile Is Not
Agile101 - What Agile Is and What Agile Is NotDerek Huether
 
Agile Methodology Vs. Others by Sara Berrada
Agile Methodology Vs. Others by Sara BerradaAgile Methodology Vs. Others by Sara Berrada
Agile Methodology Vs. Others by Sara BerradaAgile ME
 
Scaling Agile and Scrum (cPrime/Angela Johnson)
Scaling Agile and Scrum (cPrime/Angela Johnson)Scaling Agile and Scrum (cPrime/Angela Johnson)
Scaling Agile and Scrum (cPrime/Angela Johnson)Cprime
 
Dare to Explore: Discover ET!
Dare to Explore: Discover ET!Dare to Explore: Discover ET!
Dare to Explore: Discover ET!Raj Indugula
 
Agile Intro - Saint Louis Day of Dot Net
Agile Intro - Saint Louis Day of Dot NetAgile Intro - Saint Louis Day of Dot Net
Agile Intro - Saint Louis Day of Dot NetBrian Blanchard
 
Agile Software Development, Overview
Agile Software Development, OverviewAgile Software Development, Overview
Agile Software Development, OverviewBayard Randel
 
Agile Transformation: People, Process and Tools to Make Your Transformation S...
Agile Transformation: People, Process and Tools to Make Your Transformation S...Agile Transformation: People, Process and Tools to Make Your Transformation S...
Agile Transformation: People, Process and Tools to Make Your Transformation S...QASymphony
 
Agile Testing: The Role Of The Agile Tester
Agile Testing: The Role Of The Agile TesterAgile Testing: The Role Of The Agile Tester
Agile Testing: The Role Of The Agile TesterDeclan Whelan
 
Learning from the Trenches: Scrum for Hardware
Learning from the Trenches: Scrum for HardwareLearning from the Trenches: Scrum for Hardware
Learning from the Trenches: Scrum for HardwareJohn Carter
 
Leanstartuptoolsforproductowners
LeanstartuptoolsforproductownersLeanstartuptoolsforproductowners
LeanstartuptoolsforproductownersRaj Indugula
 
Seven elements of technical Agility - Gil Broza - Agile Israel 2013
Seven elements of technical Agility - Gil Broza - Agile Israel 2013Seven elements of technical Agility - Gil Broza - Agile Israel 2013
Seven elements of technical Agility - Gil Broza - Agile Israel 2013AgileSparks
 

What's hot (20)

Effective Testing Practices in an Agile Environment
Effective Testing Practices in an Agile EnvironmentEffective Testing Practices in an Agile Environment
Effective Testing Practices in an Agile Environment
 
Why Scaling Agile Doesn't Work (and What to Do About It)
Why Scaling Agile Doesn't Work (and What to Do About It)Why Scaling Agile Doesn't Work (and What to Do About It)
Why Scaling Agile Doesn't Work (and What to Do About It)
 
Agile basics
Agile basicsAgile basics
Agile basics
 
Agile Executive Briefing - Situational Assessment + 50k Ft View
Agile Executive Briefing - Situational Assessment + 50k Ft ViewAgile Executive Briefing - Situational Assessment + 50k Ft View
Agile Executive Briefing - Situational Assessment + 50k Ft View
 
How to measure the outcome of agile transformation
How to measure the outcome of agile transformationHow to measure the outcome of agile transformation
How to measure the outcome of agile transformation
 
About Agile & PMI Agile Certified Practitioner (PMI-ACP) Overview
About Agile & PMI Agile Certified Practitioner (PMI-ACP) OverviewAbout Agile & PMI Agile Certified Practitioner (PMI-ACP) Overview
About Agile & PMI Agile Certified Practitioner (PMI-ACP) Overview
 
Building Quality In in SAFe – The Testing Organization’s Perspective
Building Quality In in SAFe – The Testing Organization’s Perspective	  Building Quality In in SAFe – The Testing Organization’s Perspective
Building Quality In in SAFe – The Testing Organization’s Perspective
 
Agile testing
Agile testingAgile testing
Agile testing
 
Agile101 - What Agile Is and What Agile Is Not
Agile101 - What Agile Is and What Agile Is NotAgile101 - What Agile Is and What Agile Is Not
Agile101 - What Agile Is and What Agile Is Not
 
Agile Methodology Vs. Others by Sara Berrada
Agile Methodology Vs. Others by Sara BerradaAgile Methodology Vs. Others by Sara Berrada
Agile Methodology Vs. Others by Sara Berrada
 
Scaling Agile and Scrum (cPrime/Angela Johnson)
Scaling Agile and Scrum (cPrime/Angela Johnson)Scaling Agile and Scrum (cPrime/Angela Johnson)
Scaling Agile and Scrum (cPrime/Angela Johnson)
 
Dare to Explore: Discover ET!
Dare to Explore: Discover ET!Dare to Explore: Discover ET!
Dare to Explore: Discover ET!
 
Agile Intro - Saint Louis Day of Dot Net
Agile Intro - Saint Louis Day of Dot NetAgile Intro - Saint Louis Day of Dot Net
Agile Intro - Saint Louis Day of Dot Net
 
Agile Software Development, Overview
Agile Software Development, OverviewAgile Software Development, Overview
Agile Software Development, Overview
 
Agile Transformation: People, Process and Tools to Make Your Transformation S...
Agile Transformation: People, Process and Tools to Make Your Transformation S...Agile Transformation: People, Process and Tools to Make Your Transformation S...
Agile Transformation: People, Process and Tools to Make Your Transformation S...
 
Agile Testing: The Role Of The Agile Tester
Agile Testing: The Role Of The Agile TesterAgile Testing: The Role Of The Agile Tester
Agile Testing: The Role Of The Agile Tester
 
Learning from the Trenches: Scrum for Hardware
Learning from the Trenches: Scrum for HardwareLearning from the Trenches: Scrum for Hardware
Learning from the Trenches: Scrum for Hardware
 
Leanstartuptoolsforproductowners
LeanstartuptoolsforproductownersLeanstartuptoolsforproductowners
Leanstartuptoolsforproductowners
 
Seven elements of technical Agility - Gil Broza - Agile Israel 2013
Seven elements of technical Agility - Gil Broza - Agile Israel 2013Seven elements of technical Agility - Gil Broza - Agile Israel 2013
Seven elements of technical Agility - Gil Broza - Agile Israel 2013
 
Agile dashboard
Agile dashboardAgile dashboard
Agile dashboard
 

Similar to Agile Testing - What is it?

PMI-ACP Lesson 06 Quality
PMI-ACP Lesson 06 QualityPMI-ACP Lesson 06 Quality
PMI-ACP Lesson 06 QualityThanh Nguyen
 
Topic production code
Topic production codeTopic production code
Topic production codeKavi Kumar
 
Test driven development
Test driven developmentTest driven development
Test driven developmentHarry Potter
 
Test driven development
Test driven developmentTest driven development
Test driven developmentLuis Goldster
 
Test driven development
Test driven developmentTest driven development
Test driven developmentTony Nguyen
 
Test driven development
Test driven developmentTest driven development
Test driven developmentYoung Alista
 
Test driven development
Test driven developmentTest driven development
Test driven developmentJames Wong
 
Test driven development
Test driven developmentTest driven development
Test driven developmentFraboni Ec
 
Increasing Quality with DevOps
Increasing Quality with DevOpsIncreasing Quality with DevOps
Increasing Quality with DevOpsCoveros, Inc.
 
Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)Abhijeet Vaikar
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentnikhil sreeni
 
How to build confidence in your release cycle
How to build confidence in your release cycleHow to build confidence in your release cycle
How to build confidence in your release cycleDiUS
 
Cleaner Code Through Test-Driven Development
Cleaner Code Through Test-Driven DevelopmentCleaner Code Through Test-Driven Development
Cleaner Code Through Test-Driven DevelopmentAll Things Open
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Hong Le Van
 
The 10 commandments of an agile tester in a legacy world
The 10 commandments of an agile tester in a legacy worldThe 10 commandments of an agile tester in a legacy world
The 10 commandments of an agile tester in a legacy worldAgilePractitionersIL
 

Similar to Agile Testing - What is it? (20)

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Methodology: IT test
Methodology: IT testMethodology: IT test
Methodology: IT test
 
PMI-ACP Lesson 06 Quality
PMI-ACP Lesson 06 QualityPMI-ACP Lesson 06 Quality
PMI-ACP Lesson 06 Quality
 
Agile testing
Agile testingAgile testing
Agile testing
 
Topic production code
Topic production codeTopic production code
Topic production code
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Tdd
TddTdd
Tdd
 
Increasing Quality with DevOps
Increasing Quality with DevOpsIncreasing Quality with DevOps
Increasing Quality with DevOps
 
Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
How to build confidence in your release cycle
How to build confidence in your release cycleHow to build confidence in your release cycle
How to build confidence in your release cycle
 
Cleaner Code Through Test-Driven Development
Cleaner Code Through Test-Driven DevelopmentCleaner Code Through Test-Driven Development
Cleaner Code Through Test-Driven Development
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++
 
The 10 commandments of an agile tester in a legacy world
The 10 commandments of an agile tester in a legacy worldThe 10 commandments of an agile tester in a legacy world
The 10 commandments of an agile tester in a legacy world
 
TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
 

More from Intelliware Development Inc.

Enterprise Wearables: Wearing Our Parts On Our Sleeves - How Wearable Technol...
Enterprise Wearables: Wearing Our Parts On Our Sleeves - How Wearable Technol...Enterprise Wearables: Wearing Our Parts On Our Sleeves - How Wearable Technol...
Enterprise Wearables: Wearing Our Parts On Our Sleeves - How Wearable Technol...Intelliware Development Inc.
 
UX – A Way of Thinking, Lessons from the Real World
UX – A Way of Thinking, Lessons from the Real WorldUX – A Way of Thinking, Lessons from the Real World
UX – A Way of Thinking, Lessons from the Real WorldIntelliware Development Inc.
 
Everyone can learn to code: a starter's guide to software development
Everyone can learn to code: a starter's guide to software developmentEveryone can learn to code: a starter's guide to software development
Everyone can learn to code: a starter's guide to software developmentIntelliware Development Inc.
 
The HL7 Games: Catching FHIR - Healthcare Standards after v3
The HL7 Games: Catching FHIR - Healthcare Standards after v3The HL7 Games: Catching FHIR - Healthcare Standards after v3
The HL7 Games: Catching FHIR - Healthcare Standards after v3Intelliware Development Inc.
 
21 Compelling Software Development Facts & Figures: Software Stats
21 Compelling Software Development Facts & Figures: Software Stats21 Compelling Software Development Facts & Figures: Software Stats
21 Compelling Software Development Facts & Figures: Software StatsIntelliware Development Inc.
 
Canadian Healthcare Codes and Terminology Standards
Canadian Healthcare Codes and Terminology StandardsCanadian Healthcare Codes and Terminology Standards
Canadian Healthcare Codes and Terminology Standards Intelliware Development Inc.
 
2012 Toronto Liferay Roadshow - Mobilizing Your Enterprise
2012 Toronto Liferay Roadshow - Mobilizing Your Enterprise2012 Toronto Liferay Roadshow - Mobilizing Your Enterprise
2012 Toronto Liferay Roadshow - Mobilizing Your EnterpriseIntelliware Development Inc.
 
Web accessibility for municipalities - How to meet compliance requirements an...
Web accessibility for municipalities - How to meet compliance requirements an...Web accessibility for municipalities - How to meet compliance requirements an...
Web accessibility for municipalities - How to meet compliance requirements an...Intelliware Development Inc.
 

More from Intelliware Development Inc. (18)

Agile Room Team Dynamics
Agile Room Team DynamicsAgile Room Team Dynamics
Agile Room Team Dynamics
 
Agile Project Estimating
Agile Project EstimatingAgile Project Estimating
Agile Project Estimating
 
Agile Release & Iteration Planning
Agile Release & Iteration PlanningAgile Release & Iteration Planning
Agile Release & Iteration Planning
 
7 Myths of Agile Development
7 Myths of Agile Development7 Myths of Agile Development
7 Myths of Agile Development
 
What is Agile Development?
What is Agile Development?What is Agile Development?
What is Agile Development?
 
Enterprise Wearables: Wearing Our Parts On Our Sleeves - How Wearable Technol...
Enterprise Wearables: Wearing Our Parts On Our Sleeves - How Wearable Technol...Enterprise Wearables: Wearing Our Parts On Our Sleeves - How Wearable Technol...
Enterprise Wearables: Wearing Our Parts On Our Sleeves - How Wearable Technol...
 
Agile Testing
Agile Testing  Agile Testing
Agile Testing
 
UX – A Way of Thinking, Lessons from the Real World
UX – A Way of Thinking, Lessons from the Real WorldUX – A Way of Thinking, Lessons from the Real World
UX – A Way of Thinking, Lessons from the Real World
 
Everyone can learn to code: a starter's guide to software development
Everyone can learn to code: a starter's guide to software developmentEveryone can learn to code: a starter's guide to software development
Everyone can learn to code: a starter's guide to software development
 
The HL7 Games: Catching FHIR - Healthcare Standards after v3
The HL7 Games: Catching FHIR - Healthcare Standards after v3The HL7 Games: Catching FHIR - Healthcare Standards after v3
The HL7 Games: Catching FHIR - Healthcare Standards after v3
 
21 Compelling Software Development Facts & Figures: Software Stats
21 Compelling Software Development Facts & Figures: Software Stats21 Compelling Software Development Facts & Figures: Software Stats
21 Compelling Software Development Facts & Figures: Software Stats
 
Agile Room Dynamics
Agile Room Dynamics   Agile Room Dynamics
Agile Room Dynamics
 
Canadian Healthcare Codes and Terminology Standards
Canadian Healthcare Codes and Terminology StandardsCanadian Healthcare Codes and Terminology Standards
Canadian Healthcare Codes and Terminology Standards
 
Agile Story Writing
Agile Story WritingAgile Story Writing
Agile Story Writing
 
Agile Release & Iteration Planning
Agile Release & Iteration Planning   Agile Release & Iteration Planning
Agile Release & Iteration Planning
 
Agile Estimating
Agile Estimating Agile Estimating
Agile Estimating
 
2012 Toronto Liferay Roadshow - Mobilizing Your Enterprise
2012 Toronto Liferay Roadshow - Mobilizing Your Enterprise2012 Toronto Liferay Roadshow - Mobilizing Your Enterprise
2012 Toronto Liferay Roadshow - Mobilizing Your Enterprise
 
Web accessibility for municipalities - How to meet compliance requirements an...
Web accessibility for municipalities - How to meet compliance requirements an...Web accessibility for municipalities - How to meet compliance requirements an...
Web accessibility for municipalities - How to meet compliance requirements an...
 

Recently uploaded

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 

Recently uploaded (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

Agile Testing - What is it?

  • 1. Agile Testing BC Holmes @bcholmesdotorg © 2015 Intelliware Development Inc.
  • 2. What you’ll learn in this presentation: • Why do we use Agile testing? • What Agile testing isn’t • What Agile testing is: unit testing and test-driven development (TDD) • High-level properties of good tests • Testing in different languages • Test suites and code coverage • Using mock objects to help isolate units • Beyond unit testing © 2015 Intelliware Development Inc.
  • 3. Design • A test usually provides a concrete usage scenario that helps a developer think about the following when writing code: • What is the code expected to do? • How will the code be set up and executed? • What other pieces of code are needed as collaborators, and how will the code interact with them? • Especially good at helping to write code that is loosely coupled. 3© 2015 Intelliware Development Inc. Why do we use Agile testing?
  • 4. Why do we use Agile testing? Focus/Rhythm • Unit tests provide an easy way for a developer to focus on a particular coding task. • Clear and fast feedback if the code is working or not. • Always clear what to do next: • Either fix a failing test or write a new test as a prelude to adding functionality. 4© 2015 Intelliware Development Inc.
  • 5. What Agile testing isn’t Agile Testing is not a “phase”. • In traditional methodologies, testing is a phase of the project that happens after coding. • In Agile methodologies, coding, refactoring and testing are tightly inter-related tasks and can’t be separated. A testing “phase” that’s months, weeks or even days in the future provides very slow feedback to developers. • Faster feedback gets failure information to developers while the details of the code implementation is still fresh in their minds. 5© 2015 Intelliware Development Inc.
  • 6. What Agile testing isn’t (continued) Agile testing is not a replacement for quality assurance (QA) testing. • Agile testing is a practice to help developers create better code. • Agile testing is intended to improve the quality (design, defects, etc.) of the final code deliverables. • That might mean that you have a lower need for QA, but not necessarily. 6 It’s noteworthy that Lisa Crispen’s book, Agile Testing, is principally about the role of dedicated QA-style testers on Agile projects, rather than the testing practices of Agile developers. © 2015 Intelliware Development Inc.
  • 7. What Agile testing is: unit testing and test-driven development © 2015 Intelliware Development Inc.
  • 8. Test-driven development (TDD) TDD is one of the earliest forms of Agile testing, and the most commonly implemented types of Agile testing. It’s a style of programming in which three activities are tightly interwoven: coding, testing (in the form of writing unit tests) and design (in the form of refactoring). • Write a "single" unit test describing an aspect of the program. • Run the test, which should fail because the program lacks that feature. • Write "just enough" code, the simplest possible, to make the test pass. • "Refactor" the code until it conforms to the simplicity criteria. • Repeat, "accumulating" unit tests over time. 8 Source: Agile Alliance © 2015 Intelliware Development Inc.
  • 9. Origins 9© 2015 Intelliware Development Inc.
  • 10. What is a unit test? “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 if they are fit for use. Intuitively, one can view a unit as the smallest testable part of an application. […] In object-oriented programming, a unit is often an entire interface, such as a class, but could be an individual method. Unit tests are short code fragments created by programmers… during the development process.” 10 Source: Wikipedia © 2015 Intelliware Development Inc.
  • 11. The TDD process 11 Commit code Create a unit test Execute the Test Fix the code so that the test runs Execute the Test Refactor the code Run all tests Automated build (includes running tests) © 2015 Intelliware Development Inc.
  • 12. Creating a simple unit test in Java • Unit tests are most commonly created using the JUnit framework. • Imagine this scenario: we’re writing code to calculate mortgage payments. 12© 2015 Intelliware Development Inc.
  • 13. Create code that tests a specific expectation 13© 2015 Intelliware Development Inc.
  • 14. Run the unit test • In this example, we’re using Eclipse’s built-in JUnit test support to run the unit test. • The red bar indicates that our test doesn’t yet pass successfully. • Note how the test name appears to clarify which test has failed. • The name gives an indication of the expected behaviour. 14© 2015 Intelliware Development Inc.
  • 15. Fix code and rerun • The developer should write enough code to make the test pass. • The green bar indicates that all the expected behaviour is correctly implemented. 15© 2015 Intelliware Development Inc.
  • 16. Rules about tests • Often, once the tests are green, the developer’s next step is to refactor code. • Refactoring involves improving the design of existing code. • Make it more readable, increase the efficiency, or remove duplication. • The tests help to ensure that the developer hasn’t broken any functionality during the refactoring. • Run all tests before committing or pushing code in to the source code repository. • If there are any broken tests, you should not commit. • Automated build processes should run all of the tests as an indication of the validity of the build artifacts. 16© 2015 Intelliware Development Inc.
  • 17. Some high-level properties of good tests © 2015 Intelliware Development Inc.
  • 18. Representative: Of events that are likely to be encountered by the user. (Not necessarily “commonly”, but likely). Hacking attempts, for example, might be likely, but not common. Non-redundant: The test shouldn’t reproduce the work of another test. Motivating: Your client will want to fix the problem exposed by this test. Properties of good tests Power: A test should reveal problems when they exist. Valid: When the test states that there’s a problem, it is a genuine problem. Value: Tests should reveal problems that the client cares about. Credible: The test should be trusted to actually test the things that people expect it to test. 18 Source: Cem Kaner © 2015 Intelliware Development Inc.
  • 19. Coverage: The test exercises a part of the code that isn’t already handled by another test. Easy to evaluate: It should be relatively easy to determine whether the test has passed or failed. Insightful: A good test should reveal things about our assumptions. Properties of good tests (continued) Performable: Designing a test that can’t actually be performed is useless. Maintainable: If the end product changes, it’s important to be able to update the tests. Repeatable: It should be easy and inexpensive to execute the test again and/or reuse it as appropriate. 19 Source: Cem Kaner © 2015 Intelliware Development Inc.
  • 20. Cost: the cost to create/execute/maintain the test should compare favourably to the value. Opportunity Cost: The test obviates the need to perform some other work. Supports troubleshooting: If the test fails, it should help the programmer identify the problem. Appropriately complex: No more complex than necessary. Accountable: Can you explain why the test exists, and can you demonstrate that it was executed? 20 Source: Cem Kaner © 2015 Intelliware Development Inc. Properties of good tests (continued)
  • 21. Testing in different languages © 2015 Intelliware Development Inc.
  • 22. Common unit test frameworks Java • JUnit, TestNG. .Net • Microsoft Unit Testing Framework and NUnit. JavaScript • Mocha, Jasmine, Unit.js, Nodeunit, QUnit, JSUnit, and many others. iOS / Objective-C • XCUnit (successor to OCUnit). Python • Nose, unittest (a.k.a. PyUnit). 22© 2015 Intelliware Development Inc.
  • 23. Unit testing with JavaScript and Mocha.js Slightly different syntax from JUnit, but most concepts are comparable. 23© 2015 Intelliware Development Inc.
  • 24. Executing Mocha.js on the command line Most JavaScript unit test frameworks are command-line-based. 24© 2015 Intelliware Development Inc.
  • 25. Unit testing with C# and Microsoft’s unit testing tools Again, slightly different syntax, but same basic concepts. 25© 2015 Intelliware Development Inc.
  • 26. Visual Studio’s built-in test support 26© 2015 Intelliware Development Inc.
  • 27. Testing with Objective-C and XCUnit 27© 2015 Intelliware Development Inc.
  • 28. XCode’s built-in support for XCUnit 28© 2015 Intelliware Development Inc.
  • 29. Successful execution 29© 2015 Intelliware Development Inc.
  • 30. Key insights Unit testing in a variety of languages (and test frameworks) is largely the same. • Test a specific function and give it a descriptive name. • Set up some necessary classes and/or data. • Invoke the function/method under test. • Check/assert that calculated values match expectations. Most test runner tools use red and green indicators to tell developers the current state of the tests. 30© 2015 Intelliware Development Inc.
  • 31. Test suites and code coverage © 2015 Intelliware Development Inc.
  • 32. Test suites Over time, as more and more tests are created, a sizeable amount of the application is backed by unit tests that are executed many times a day to ensure that previously-created functionality still works. • Hundreds or even thousands of unit tests are not uncommon for a single application. As more and more tests are added, the amount of time it takes to execute the tests increases. • If that amount of time is too long, developers will start becoming discouraged from running the tests regularly. • A few seconds is awesome. • Less than 30 seconds is still pretty good. • A few minutes isn’t terrible. • More than that is likely to be irritating. 32© 2015 Intelliware Development Inc.
  • 33. Code coverage Some languages/environments have tools that can calculate the amount of your application’s code that gets executed during the running of the unit test suite. • These tools are called “code coverage” or “test coverage” tools. High coverage usually indicates that the application is well-tested, and that usually results in developer confidence that they can change the application and not break the existing functions. • How high is high enough? There are a lot of factors and not all projects are the same, but 75% or 80% coverage is often used as a starting goal. 33© 2015 Intelliware Development Inc.
  • 34. Some stuff is hard to test Visual output • Does a web page look attractive? Is an animation jerky or glitchy? Is one component of a web page covering or obscuring another component? • Graphical output — especially image-based. • Example: a class that outputs a bar chart as a PNG image. Code that’s date/time-driven or based on timers • But if you parameterize the date/time information, you can often mitigate the difficulty. Legacy code • The best time to start unit testing code is at the beginning of a project. • Legacy code, especially tightly-coupled stuff, is harder to make testable. 34© 2015 Intelliware Development Inc.
  • 35. Using mock objects to help isolate units © 2015 Intelliware Development Inc.
  • 36. Mock objects: dealing with collaborators “In object-oriented programming, mock objects are simulated objects that mimic the behaviour of real objects in controlled ways. A programmer typically creates a mock object to test the behaviour of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behaviour of a human in vehicle impacts.” 36 Source: Wikipedia © 2015 Intelliware Development Inc.
  • 37. Tools for working with mock objects Usually involves a mock framework • Java • Mockito, Jmock • JavaScript • Sinon.js • Objective-C • OCMock 37© 2015 Intelliware Development Inc.
  • 38. Example We want to test functionality related to renewing a mortgage. • Renewing a mortgage should be based on same payment type, but current interest rate. Mortgage collaborates with a class that provides the current interest rates. • But we’re currently testing the renew functionality, not the providing of interest rates. Let’s try an example using Java and Mockito. 38© 2015 Intelliware Development Inc.
  • 39. 39 Need a special test runner © 2015 Intelliware Development Inc.
  • 40. 40© 2015 Intelliware Development Inc.
  • 41. Additional thoughts Mock object frameworks provide a powerful way to ensure that you’re testing only a single unit at a time. • Helps isolate an individual unit. If the configuration of your mock object starts to get complex or messy, that’s an indication that your class is too tightly intertwined with the mock object’s class. • Remember: loosely-coupled classes are easier to test, and usually a better design choice. 41© 2015 Intelliware Development Inc.
  • 42. Defining your units A “unit” is often a class or small collection of related classes. • Anything not contained in that “unit” is a dependency or collaborator. • We usually create mock objects to take the place of the dependency/collaborator when we build the unit test. Consider special case: a class that reads data from a database. • In Java, such classes are often referred to as “Data Access Objects” or DAOs. • Key question: does the “unit” that you’re testing include the database? • Or should the database be considered a dependency/collaborator? 42© 2015 Intelliware Development Inc.
  • 43. The case for “no” • Unit tests that connect to the database are often slower than most other unit tests. • Both because of set up and because of I/O. • You need to consider the contents of the database: does your test expect certain records? How do they get there? What if those contents are changed? Managing the initial state or “home state” of the database is a non-trivial exercise. My gut is telling me “maybe” The case for “yes” • It’s often hard to mock out an entire database API. • Including the database allows you to test more: object- relational mapping configuration, query correctness, etc. • If you use database features such as triggers or stored procedures, this might be the only way you can test those. 43© 2015 Intelliware Development Inc.
  • 44. Database tests Don’t get hung up on the name. • Whether or not they’re “unit” tests, it’s often fruitful to include tests that touch the real database. Dealing with “Home State” is often worth the initial investment. • Home state is a version of the database (or other resource) that contains the data that the tests expect. 44© 2015 Intelliware Development Inc.
  • 45. Approaches to home state Restore the database prior to running tests. • Always brings the data back to home state, but might take time. Have a separate database specifically for unit tests to use. • But need to apply necessary table definition changes as the project evolves. Don’t let unit tests change the state of the database. • Rollback any changes or undo database changes when the tests finish. • Doesn’t help if the same database is used for ad-hoc testing. Try to minimize the expectations. • Not always possible or easy. Home state management isn’t easy, but the benefits are worth it. 45© 2015 Intelliware Development Inc.
  • 46. Beyond unit testing © 2015 Intelliware Development Inc.
  • 47. Beyond unit testing Although Agile testing is often described in terms of creating unit tests, there are other forms of testing that can prove useful for an agile project. Common test types: • Integration Tests: tests that integrate a number of units, to ensure that the parts interact with one another properly. • UI Tests: tests that automate interaction with a UI and the complete application codebase to ensure that all parts function together properly. • Performance Tests: tests that automatically capture information about the response time of the application, possibly under load. • Static Analysis Tests: tests that analyze code, looking for violations of coding conventions and development rules. • Acceptance Tests: tests that demonstrate to the customer that the requested functionality has been implemented. 47© 2015 Intelliware Development Inc.
  • 48. Integration testing Sometimes, the integration between multiple units is sufficiently complex that it’s fruitful to test it. • Especially true of application-specific code that needs to be integrated with and configured in major frameworks. Examples: • Ensure that a certain number of classes are correctly configured and wired together in a Spring configuration file. • Ensure that a SOAP interface has been correctly configured to send or receive the necessary data. The goal is to integrate no more parts than absolutely necessary. 48© 2015 Intelliware Development Inc.
  • 49. Integration tests (continued) Because more parts need to be set up and initialized, integration tests may take longer than other types of tests. • Integration tests might end up being run less frequently. Still interested in this question: “Do the integration tests run quickly enough that we can expect the developers to run them prior to synching with source control?” • A “yes” answer provides more value than a “no” answer, but a “no” answer can still be helpful. 49© 2015 Intelliware Development Inc.
  • 50. UI tests Can be considered a special case of integration tests — essentially integrating all of the parts. Examples: • Web UI Tests. • Launch the full application in a web server. • Selenium is a very commonly-used web UI test tool. • Mobile UI Tests • There are many approaches to building mobile apps. • Native, HTML5 or Mobile Application Development Platforms (MADPs) like Worklight, Kony or Appcelerator Titanium. • As a result, no one mobile UI test tool has become de facto standard, so mobile UI testing is still an emerging discipline. 50© 2015 Intelliware Development Inc.
  • 51. Performance tests • If one of the requirements (user stories) of your application involves performance targets, testing is the ideal way to ensure that those targets are met. • While Agile developers often caution against premature performance optimization, it’s also not necessarily a good idea to wait until the end of a project to test performance. • Performance testing often tests the integration of many of the parts of the application, rather than just individual units. • We frequently instrument applications to gather performance metrics, and run a suite of performance tests that can give us a performance checkpoint with every build. 51© 2015 Intelliware Development Inc.
  • 52. Automated performance test report Three types of data: • What’s the current performance, at the highest level (see diagram)? • What’s the current performance at different layers of the application (Service Layer, DAO Layer). • What the historical performance? 52© 2015 Intelliware Development Inc.
  • 53. Static analysis tests • Developers tend to think of functional business requirements as the things that drive unit tests. • Unit tests can additionally be built around non-functional requirements or even development rules or standards. • Examples: • Organization has a web standard to use relative units (e.g.: rems) rather than pixel units (px) in web page style sheets (CSS). • Write a unit test that scans all of the CSS and fails if px units are found. • Architectural standard that Java code should not have cyclical package dependencies. • Write a unit test that fails if package cycles are found. 53© 2015 Intelliware Development Inc.
  • 54. Static analysis tests (continued) • Provides proactive identification of problems, rather than after-the-fact need for clean-up. • Interesting consequence: • Tests continue to enforce rules as more code or more developers are added to the project. • Developers can’t say, “nobody told me about that rule!”. 54© 2015 Intelliware Development Inc.
  • 55. Acceptance tests • An acceptance test is a description of a scenario that demonstrates the expected behaviour of a software component. • Ideally, the acceptance test is recorded in a way that’s readable by a customer (and developers), but still supports automated execution. • Several tools such as JBehave or Cucumber, attempt to make acceptance tests readable while still providing automated execution. • Acceptance Testing is often tied to the idea of “Behaviour Driven Development”. • Emphasizes “specifications” and “scenarios”. • Many BDD proponents like the “Given-When-Then” structure. • Given a particular context, when an action is taken, then a particular result is expected. 55© 2015 Intelliware Development Inc.
  • 56. 56© 2015 Intelliware Development Inc. About Intelliware Development Inc. Intelliware is a custom software, mobile solutions and product development company headquartered in Toronto, Canada. Intelliware is a leader in Agile software development practices which ensure the delivery of timely high quality solutions for clients. Intelliware is engaged as a technical partner by a wide range of organizations in sectors that span Financial Services, Healthcare, ICT, Retail, Manufacturing and Government. /company/intelliware-development-inc- /intelliware.inc /intelliware_inc /GooglePlusIntelliware www.intelliware.com
  • 57. © 2015 Intelliware Development Inc. Check out other entries in our Agile methodology series 57