Test Generation: Model Based Testing

Test Generation: Model Based Testing

The Importance of Automated Test Generation

Cost and Benefits of Testing

  • The benefits of testing are significant, but they come with associated costs. Reducing these costs is crucial.
  • Automating the test generation process could alleviate the burden on developers who often lack motivation to write tests.

Exploring Automated Test Creation

  • Researchers are investigating whether it's possible to eliminate costs through automated test creation using formal specifications of systems.
  • Tests can be represented as paths in a state machine model, where each path corresponds to a potential test scenario.

Model-Based Testing Approaches

  • Model-based testing derives test cases from detailed system specifications, such as state machines.
  • While creating comprehensive specifications can be expensive, it ultimately reduces overall testing costs.

Simplified Specifications for Testing

  • It's not always feasible to create complete specifications; simpler forms can still yield effective tests.
  • An example involves using JML (Java Modeling Language) for specifying preconditions and postconditions related to methods.

Generating Tests Automatically

  • Preconditions dictate when a method should be called, while postconditions verify expected outcomes after execution.
  • A tool can generate tests by creating random inputs that satisfy preconditions and then checking if postconditions hold true after method execution.

Practical Application of Generated Tests

  • The generated tests simplify the process by ensuring that arrays are sorted correctly based on specified conditions.
Playlists: Testing+