Slidings 8 + 9 - Junit Test Framework Flashcards
Constructive Approach (Ansatz)
“Whenever you are tempted to type something into a print statement or a
debugger expression, write it as a test instead.”
Requirements for a Unit Test Framework
- Simple and suitable for programmers
● No unnecessary effort
● No new language! - Automated test execution
● Regression testing anytime and efficiently
● Integration in automated build-processes - High Reuse (Hohe Wiederverwendung)
● Existing tests should be used to create new ones
● Extending a test suite should be easily possible
Concepts
Test class
● contains all test methods and all lifecycle methods
Test method
● implements a test case and especially the expected/actual-comparison
Lifecycle method
● Set-up: prepares the precondition
● Tear-down: cleans up after the execution
Suite
● aggregates many test classes
Runner ● executes a single test class or a test suite
Result
● contains statistic information about the tests (number etc.)
● contains information about tests detecting an error/failure
Failure
● contains information for every test that fails
Error
● indicates, that a test case has been terminated unexpectedly
Testing
Activity in which a system or component is executed under specified conditions, the results are observed or recorded, and an evaluation is made of some aspect of the system or component
- Testing is the process of executing a program with the intent of finding errors.
What is not a test?
● any kind of program inspection
● program demonstration
● program analysis by means of software tools
What is a Successful Test?
● Detect errors!
● A test (case) is successful, if it discovers an error!
● A test is never a proof for a correct program!
-> It has just found no errors!
Classification - Systematics
Trial run
● Developer compiles, binds and starts the program
● Eventually the program can be executed
● Results are not obviously wrong
Throw-away Test
● Somebody provides input data and executes the program
● Sometimes errors are discovered
Systematic Test
● The test data (test input data and expected results) is systematically derived from the specification/test model
● The program is executed
● The actual results are compared again the expected results
● The test process is documented (test item, test data,
actual results)
Classification – Unit under Test (UuT)
● Unit Test
● Component Test
● System Test
● Integration Test
Acceptance Testing
● Examines a system/ a component against defined
acceptance criteria
- User Acceptance Test
- Operational Acceptance Test
● The goal is not to discover errors!
- It should be shown, that the system fulfills the given
criteria, i.e., it works in all tested cases
Difference: Alpha and Beta Testing
● Alpha testing is done by the development organization
● Beta testing is done by selected special customers
Test Case Selection
● Black-Box Testing (functional testing)
->Design based on the specification
● Glass-Box Testing (structural testing)
-> aka white-box testing
-> Design based on internal structure
-> Specification is needed, too (to determine the
expected results)
Exhaustive Test
There are x alternatives to execute a program and all x alternatives are tested.
–> This is only feasible in rare cases (in seltenen fällen)
Advantages of Tests
- Testing is a natural examination process!
- Tests are reproducible! (→ objective)
- The invested effort is reusable several times!
- The target environment is also tested!
- System behavior is made visible!
Drawbacks
- Results are often overrated! (no correctness statement)
- Not all program properties can be tested!
- Not all application situations can be simulated!
- The test does not show the defect