The goal of testing is to gain assurance about the quality of your programs
The testing you do for your class assignments is more likely to be debugging oriented
Testing
Running a program on various inputs
Any human or computer assessment of quality
Evaluations before writing code
The earlier we find a problem, the easier and cheaper it is to fix
Maintenance activities consume 70-90% of the total cost of software
Some software engineering approaches advocate writing test cases BEFORE you even write any code
The earlier you find a defect, the cheaper it is to fix
Modern day testing is preventive
Software maintenance
Modifying a program after it has been put into use
Maintenance does not normally involve major changes to the system's architecture
Changes are implemented by modifying existing components and adding new components to the system
Maintenance requires program understanding
When the transition from development to evolution is not seamless, the process of changing the software after delivery is often called software maintenance
Importance of maintenance
Organizations have huge investments in their software systems - they are critical business assets
To maintain the value of these assets to the business, they must be changed and updated
Much of the software budget in large companies is for modifying existing software
We cannot avoid changing software
A key problem for organizations is implementing and managing change to their existing software systems
Review
A meeting in which several people examine a design document or section of code
It is a common and effective form of human-based testing
Presenting a design or code to others makes us think more carefully about it and provides an outside perspective
Test case
A set of input and user actions, coupled with the expected results
Often test cases are organized formally into test suites which are stored and reused as needed (like JUnit)
For medium and large systems, testing must be a carefully managed process
Many organizations have a separate Quality Assurance (QA) department to lead testing efforts
Defect testing
The execution of test cases to find errors
The act of fixing an error may introduce new errors
After fixing a set of errors we should perform regression testing - running previous test suites to ensure new errors haven't been introduced
It is not possible (in general) to create test cases for all possible input and user actions
Black-box testing
Test cases are developed without considering the internal logic
They are based on the input and expected output
Input can be organized into equivalence categories
Two input values in the same equivalence category would produce similar results
A good test suite will cover all equivalence categories and focus on the boundaries between categories
White-box testing
Focuses on the internal structure of the code
The goal is to ensure that every path through the code is tested
Paths through the code are governed by any conditional or looping statements in a program
A good testing effort will include both black-box and white-box tests
Defining what correctness means is a tough problem
JUnit
Unit testing for Java
Provides individual test cases that target specific units of code, usually a specific method or a specific branch of code
Offers a form of regression testing: make a few changes, re-run all JUnit tests to check if we broke previously-tested code
JUnit test methods
assertTrue(boolExpr)
assertEquals(Object expected, Object actual)
assertNotNull(Object o)
JUnit integrates very well with IDEs (also works on command-line)
The goal of testing is to gain assurance about the quality of your programs
The testing you do for your class assignments is more likely to be debugging oriented
Testing
Running a program on various inputs
Any human or computer assessment of quality
Evaluations before writing code
The earlier we find a problem, the easier and cheaper it is to fix
Maintenance activities consume 70-90% of the total cost of software
Some software engineering approaches advocate writing test cases BEFORE you even write any code
The earlier you find a defect, the cheaper it is to fix
Modern day testing is preventive
Software maintenance
Modifying a program after it has been put into use
Maintenance does not normally involve major changes to the system's architecture
Changes are implemented by modifying existing components and adding new components to the system
Maintenance requires program understanding
Organizations have huge investments in their software systems - they are critical business assets
Much of the software budget in large companies is for modifying existing software
We cannot avoid changing software
Reasons for software changes
New requirements emerge when the software is used
The business environment changes
Faults must be repaired
New computers and equipment is added to the system
The performance or reliability of the system may have to be improved
A key problem for organizations is implementing and managing change to their existing software systems
Review
A meeting in which several people examine a design document or section of code
It is a common and effective form of human-based testing
Presenting a design or code to others makes us think more carefully about it and provides an outside perspective
Test case
A set of input and user actions, coupled with the expected results
Often test cases are organized formally into test suites which are stored and reused as needed (like JUnit)
For medium and large systems, testing must be a carefully managed process