Skip to main content


Unit testing of the BSW layer in AUTOSAR is critical for reliable, safe, and performant automotive software. It improves system reliability by catching issues early and ensures safety by eliminating failures. AUTOSAR’s modularity allows efficient unit testing of individual modules, improving maintainability. However, challenges exist. The BSW layer’s complexity and interdependence make test creation difficult. Real-time constraints and limited resources of embedded systems add to the challenge. Hardware dependencies can hinder testing in simulated environments. Finally, a lack of standardization can lead to inconsistent testing practices. By overcoming these challenges, developers can ensure a robust BSW layer, forming the foundation for successful AUTOSAR systems.

Problem Statement

An automotive client utilizing its own custom developed AUTOSAR architecture stack faced significant challenges in achieving comprehensive unit test coverage for their Basic Software (BSW) layer. Tight coupling between BSW components and other software modules within AUTOSAR stack complicated the isolation required for effective unit testing. Furthermore, the BSW layer, especially modules like the communication stack, diagnostic stack, and system services, operate under stringent real-time constraints. Traditional unit testing methods struggle to replicate these real-time conditions, hindering the testing process. The inherent complexity of these BSW modules, which handle intricate interactions like message transmission and reception with demanding error handling procedures, further exacerbates the challenge.

The client seeks a cost-effective solution that leverages Specialized Testing Platforms. These platforms should be affordable and cater to the specific needs of real-time embedded system testing, including features like mocking and stubbing to facilitate component isolation. Additionally, the client desires to engage a team of testing experts with a deep understanding of AUTOSAR architecture, BSW functionalities, and best practices for unit testing real-time and complex software components.


Building upon the understanding of the client’s challenges, the Google Test framework emerged as a compelling solution due to its distinct advantages like,

  • Automated Execution: Streamlines regression testing during development and CI pipelines.
  • AUTOSAR Compatibility: Supports diverse development environments and target architectures
    commonly used in AUTOSAR projects, ensuring seamless integration within the existing client
  • Mock Object Capabilities: Enables isolated unit testing of BSW components by simulating external
    dependencies and complex interactions. This facilitates efficient defect identification within the
    intricate BSW layer, addressing the challenge of tight coupling within the system.
  • Customization Potential: Offers extensibility to address specific testing needs and project
    constraints within the AUTOSAR ecosystem, allowing for tailor-made solutions to the client’s unique

A significant challenge arose with the Com module, where message transmission and reception needed thorough testing. Configuration data for messages and signals was retrieved from dedicated XML files. Leveraging Python Jinja3 templates within the test files facilitated the dynamic generation of test cases based on these configurations.
The most challenging aspects were testing timing-related requirements and message transmission/reception.To address these complexities, the proposed approach involved:

  • Mock-Driven Unit Testing with Google Test:
    Leveraging Stubs: Mock header files (.h) with stubs are incorporated in test files. Google Test’s built-in mocking functionality facilitates the creation of mock objects. These mocks simulate external dependencies or complex interactions within the BSW, enabling isolated unit testing of the target code by decoupling it from external components.
  • Efficient Resource Management:
    Constructor/Destructor Optimization: Constructors and destructors were employed for proper initialization and de-initialization of the module and its variables. This promoted efficient resource management and memory handling.
  • Enhancing Reusability and Reliability:
    Test Fixture Implementation: Test fixtures were utilized to establish and dismantle common resources and state across multiple test cases. This approach minimized code duplication and guarantees consistent testing environments.
  • Parameterized Testing for Comprehensive Coverage:
    Parameterized tests were introduced to automate the execution of test cases with varying input parameters. This approach ensured comprehensive testing across a wider range of scenarios. Within the Com module’s configuration file, we meticulously analyzed the transmission and reception Protocol Data Units (PDUs), along with their encapsulated signals. These configurations serve as the backbone for communication integrity.


This comprehensive documentation demonstrates a commitment to quality assurance throughout the development lifecycle. By employing Google Test, we achieved thorough testing of over 32 AUTOSAR BSW modules, encompassing crucial components like the Com Stack, Safety-Critical Components, Memory Stack, and Diagnostic Stack. This rigorous testing approach, utilizing the capabilities of Google Test, ensures the robustness, safety, and reliability of the tested BSW modules.

Leave a Reply