Software Testing Techniques
Software Testing Techniques
Testing philosophies
Purpose
• Discuss some of the principles for best practices when testing code.
Structure of a Test
• Tests should test one and only functionality in a way as independent of outside influences as
possible.
• Tests should be as authentic as possible (don’t test with only integers if most user data will be
floating point).
• Tests should not depend on data external to the test framework (URLs, databases, etc)
• Tests should use all functionality of the testing harness to eliminate any “test smell” - just like
code smell.}
Goals of Testing
o Act as a specification
o Bug repellant
o Act as documentation
o Automated
o Repeatable
o Independent
o Simple
o Expressive
o Separation of Concerns
Testing Principles
o “layer crossing” testing uses the public interface and monitors the back door
o “asynchronous” testing interacts with external services (databases, remote servers) and
should be avoided at all costs
• Communicate intent
o The effort to write the test shouldn’t overshadow the effort to write the production
code.
Testing strategies
Data-Flow Testing
A way to test software called “Data-Flow Testing” looks at the paths that data variables take
through a program. This check examines how the code creates, uses, and ends data. The main
objective is to find and test the points at which variables are given values (definitions), how
these values are then used (usage), and where they are no longer used (termination).
This testing method looks at the data flow to find mistakes in how the data is being used, like
wrong variable usage, variables that haven’t been set up, and improper variable scope.
When it is used:
Data-flow testing is particularly effective in the following scenarios:
• Critical Data Handling: When the correctness of data usage is vital, such as in financial
systems or safety-critical software.
• Complex Codebases: In large or complex systems where data dependencies are intricate
and difficult to track manually.
• Maintenance and Refactoring: When modifying existing code, ensure that changes do
not introduce new data-related errors.
Pros
• Detects Data-Related Errors: Effectively identifies issues like uninitialized variables,
incorrect data usage, and unintended variable overwrites.
• Improves Code Quality: By ensuring proper data flow, it enhances the reliability and
maintainability of the code.
• Comprehensive Coverage: Provides detailed insights into how data is managed within
the code, leading to more thorough testing.
Cons
• Complexity: Analyzing data flow, especially in large systems with numerous variables
and data paths, can be complex and time-consuming.
• Requires Detailed Knowledge: Effective data-flow testing requires a deep understanding
of the code and its data dependencies.
• Tool Dependence: Manual data-flow analysis can be challenging, so specialized tools are
often needed, which might require additional learning and integration effort.
Popular Tools for Data-Flow Testing include Parasoft Jtest, LDRA Testbed, etc