Automated Testing via Intermediate Mock Classes
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Current test automation frameworks face challenges in emulating missing runtime artifacts required by classes under test, such as database queries or UI events, making it difficult to reproduce the necessary environment for testing.
Innovation Solution
The method involves inserting an intermediate mock class between the superclass and the class-under-test, automatically modifying the class-under-test at runtime by overriding methods and generating fake data without accessing a database, using a byte-code transformer engine to patch the class according to user-defined rules, and communicating with a class repository and configuration repository.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If manual testing is performed to ensure quality, then testing thoroughness is improved, but time consumption increases significantly
Solution Approach 1:
The patent creates mock objects that are copies or simulations of real runtime artifacts (database connections, HTTP sessions, UI components). These mock objects replicate the behavior and interface of the actual artifacts, allowing tests to run against the copies rather than requiring the real artifacts to be present, thus saving time while maintaining testing thoroughness
Solution Approach 2:
The patent introduces a bytecode transformation layer that acts as an intermediary between the test code and the runtime environment. This intermediary automatically injects mock objects and modifies bytecode to redirect calls to mock implementations, eliminating the need for manual test setup while preserving comprehensive testing capabilities
2Reliability
If all runtime artifacts are reproduced for testing, then test accuracy is improved, but environment complexity increases
Solution Approach 1:
The patent extracts the essential behavior and interface characteristics of runtime artifacts and encapsulates them in mock objects. Instead of reproducing the entire complex runtime environment (databases, HTTP servers, UI frameworks), the solution takes out only the necessary interaction patterns and exposes them through simplified mock implementations that can be configured with minimal effort
Solution Approach 2:
Rather than creating full replicas of complex runtime environments, the patent creates simplified copies (mock objects) that replicate only the specific methods and behaviors needed for testing. These mock copies use the same interface contracts as the real artifacts but implement them in-memory or through simplified logic, reducing environmental complexity while maintaining test accuracy
3Ease of operation
If mock objects are created using declarative languages, then ease of use is improved, but automation capability deteriorates
Solution Approach 1:
The patent implements self-service automation where the testing framework automatically performs tasks that would otherwise require manual configuration. The bytecode transformation engine automatically identifies which artifacts need mocking, creates appropriate mock objects, injects them into the test environment, and configures their behavior based on annotations or configuration files, eliminating the need for manual mock creation while maintaining ease of use through simple declarative specifications
Solution Approach 2:
The patent performs preliminary automated actions during test setup by transforming bytecode before test execution. The system pre-configures mock objects, pre-establishes their behavior based on user-defined rules, and pre-injects them into the test environment automatically. This preliminary automation eliminates the need for manual mock object creation and configuration during test execution, maintaining both ease of use and high automation capability
Data Source
AI summary
A method, computer program product, and system for automating a test environment is provided. The method may include providing, at one or more computing devices, a superclass and a class-under-test, the superclass and the class-under-test having an inheritance chain therebetween. The method may further include inserting, via the computing device, an intermediate mock class between the superclass and the class-under-test. The method may also include automatically modifying, via the computing device, the class-under-test at runtime.


