Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GeoMechanicsApplication] dgeosettlement refactoring for testability #11567

Merged
merged 10 commits into from
Sep 20, 2023

Conversation

rfaasse
Copy link
Contributor

@rfaasse rfaasse commented Sep 15, 2023

📝 Description
The RunStage function in the new DGeoSettlement workflow is not unit-tested due to dependencies on IO operations (needing the MaterialParameters.json, ProjectParameters.json etc to execute the function).

This PR extracts the IO functionality via an interface, so they can be stubbed for the unit-test. This improves testability and ensures unit-tests only test one class, without depending on other classes.

🆕 Changelog
Please summarize the changes in one list to generate the changelog:

  • An InputUtilityInterface is created, which has functions to read project parameters, MaterialSettings and mesh info. This interface is implemented in custom_workflows with the actual IO functionality and passed on in the KratosGeoSettlement constructor.
  • Unit tests are created for the KratosGeoSettlement, which is now easier to do, due to the interface extraction
  • A stub is created for the InputUtilityInterface, which is used in the new KratosGeoSettlement unit tests.

@rfaasse rfaasse marked this pull request as ready for review September 18, 2023 14:21
@rfaasse rfaasse requested a review from avdg81 September 18, 2023 14:21
@rfaasse rfaasse linked an issue Sep 18, 2023 that may be closed by this pull request
@rfaasse rfaasse added the GeoMechanics Issues related to the GeoMechanicsApplication label Sep 18, 2023
Copy link
Contributor

@avdg81 avdg81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice refactoring. I have mostly minor remarks and a few suggestions.

@rfaasse
Copy link
Contributor Author

rfaasse commented Sep 19, 2023

For documentation purposes: the 5 newly added tests run within 40 ms, since they're not dependent on any IO

image

@rfaasse rfaasse requested a review from avdg81 September 20, 2023 07:08
Copy link
Contributor

@avdg81 avdg81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice piece of work!

@rfaasse rfaasse merged commit 9b1ddf0 into master Sep 20, 2023
@rfaasse rfaasse deleted the geo/dgeosettlement-refactoring-for-testability branch September 20, 2023 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GeoMechanics Issues related to the GeoMechanicsApplication
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor KratosGeoSettlement to be able to add unit tests
2 participants