zarfld / LinuxCnc_PokeysLibComp

Pokeys comp for LinuxCnc using https://bitbucket.org/mbosnak/pokeyslib.git
MIT License
5 stars 0 forks source link

Automated Testing Setup with Mocked `pokeyslib` #66

Open zarfld opened 1 day ago

zarfld commented 1 day ago

Automated Testing Setup with Mocked pokeyslib

Description:

In order to run automated tests without requiring physical PoKeys devices, all interactions with pokeyslib should be mocked. A separate version of pokeyslib will be created specifically for testing purposes. This mock library will simulate the behavior of the PoKeys devices to ensure that the components can be tested in isolation and in conjunction with LinuxCNC without the need for hardware.

Tasks:

  1. Set Up Continuous Integration (CI) Pipeline:

    • Configure GitHub Actions for CI to automatically run tests on each push or pull request.
    • Ensure the CI pipeline runs on debian-latest (or another suitable environment) with LinuxCNC.
    • The CI pipeline should be configured for both user-space and real-time components (pokeys_py, pokeys_rt, pokeys.comp).
  2. Create a Mock Version of pokeyslib:

    • Develop a mock version of pokeyslib that simulates PoKeys device behavior.
    • The mock version should replicate the API of the real pokeyslib but provide controlled, predictable outputs.
    • Ensure that the mock library includes simulations for all major components: Digital IO, Analog IO, Counters, PWM, and PEv2.
    • Include mock responses for device setup, configuration, and data retrieval.
  3. Create Unit Tests Using the Mocked pokeyslib:

    • Implement unit tests for each major component (Digital IO, Analog IO, PWM, PEv2, PoExtBus, etc.).
    • Use the mock version of pokeyslib to simulate hardware responses during tests.
    • Ensure tests validate both correct inputs and error conditions.
  4. Create Integration Tests:

    • Set up integration tests to validate interaction between pokeys_py, pokeys_rt, pokeys.comp, and LinuxCNC.
    • Test custom homing procedures, digital/analog IO, counters, and PWM with the mocked pokeyslib.
    • Use LinuxCNC’s simulation mode to run the tests without requiring real-time hardware.
  5. Implement Mock-Specific CI Pipeline:

    • Add a CI pipeline that uses the mocked version of pokeyslib.
    • Ensure the pipeline runs both unit and integration tests with the mock library.
    • Ensure that the pipeline works with LinuxCNC in simulation mode.
  6. Test LinuxCNC Integration:

    • Validate that components interact correctly with LinuxCNC using the mock library and simulation mode.
    • Test the custom homing process and ensure pokeys_homecomp.comp works as expected with LinuxCNC.
  7. Add Coverage Reports:

    • Use coverage.py to generate code coverage reports.
    • Ensure coverage reports are uploaded to GitHub or a third-party service (e.g., Codecov).
    • Include both unit and integration test coverage.
  8. Document the Testing Process:

    • Create a TESTING.md file with instructions for setting up and running tests locally and in CI.
    • Include detailed information on using the mock pokeyslib, LinuxCNC simulation mode, and how to troubleshoot issues.

Acceptance Criteria:

References: