Skip to content

feat: unit testing framework#48

Merged
akselthomsen merged 34 commits intomainfrom
feat/component-unit-testing
Feb 18, 2026
Merged

feat: unit testing framework#48
akselthomsen merged 34 commits intomainfrom
feat/component-unit-testing

Conversation

@akselthomsen
Copy link
Copy Markdown
Member

@akselthomsen akselthomsen commented Sep 15, 2025

Summary

Updates the unit testing workflow for a component.

A component being tested now has it's own class (mighty_component_test) that tracks test coverage,
and a separate and dedicated child R session to execute code in.

The new workflow is a follows:

  1. Create test component with get_test_component()
  2. Assign input data with $assign()
  3. Execute and track coverage with $eval()
  4. Retrieve results with $get()
  5. Test results with expect_*() functions from {testthat}

The best way to see how a user will test components is see the updated tests/testthat/test-components.R that tests the dummy standard components currently inside the package.

I decided not to create a separate testing vignette in this PR.
I will include testing as part of the Getting Started vignette in #28.

Changes Made

  • New mighty_component_test class. Inheriting from mighty_component_rendered.
  • Corresponding get_test_component() function. On exit it by default checks if all lines of the test component has been covered by unit tests.
  • The mighty_component_test has methods to $assign() and $get() variables from the child R session. The print() method also displays code coverage (in total and by each line).
  • Updated $eval() method for mighty_component_rendered to print evaluated code to the console using zephyr verbosity_level option to suppress it. This was part of a previous iteration on the test development, but I liked it so much I wanted to keep it.
  • Fixed legacy mentions of standards
  • Fixed legacy use of .self in examples

Testing

  • All code have unit tests
  • New unit tests for mighty_component_test that checks if the workflow and coverage checks work. Snapshots for tracking the development in code coverage with the printing method.
  • Updated tests for the dummy standard components to validate the general workflow.

Checklist

  • Code changes have been tested
  • Documentation has been updated, if applicable
  • All automated tests pass
  • Coding style and naming conventions have been followed
  • The PR is ready for review and merge

@akselthomsen akselthomsen linked an issue Oct 22, 2025 that may be closed by this pull request
@akselthomsen akselthomsen mentioned this pull request Jan 12, 2026
5 tasks
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@NovoNordisk-OpenSource NovoNordisk-OpenSource deleted a comment from github-actions[bot] mannequin Feb 6, 2026
@NovoNordisk-OpenSource NovoNordisk-OpenSource deleted a comment from github-actions[bot] mannequin Feb 6, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 6, 2026

Code coverage

Name Coverage (%)
mighty.component 100
R/component.R 100
R/custom_r.R 100
R/mighty_component_rendered.R 100
R/mighty_component_test.R 100
R/mighty_component.R 100
R/standard.R 100
R/utils-validation.R 100
R/validate_component_code.R 100
R/validate_implicit_join.R 100

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 6, 2026

Github pages

Review the pkgdown webpage for the PR here

@akselthomsen akselthomsen marked this pull request as ready for review February 9, 2026 09:37
@akselthomsen akselthomsen merged commit 3c28664 into main Feb 18, 2026
15 checks passed
@akselthomsen akselthomsen deleted the feat/component-unit-testing branch February 18, 2026 11:51
@akselthomsen akselthomsen linked an issue Feb 26, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Create unit testing framework for standard components

3 participants