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

Refactor unit tests in MedicationRequestMapperTests to use nested classes. #869

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

MartinWheelerMT
Copy link
Collaborator

What

Refactor unit tests in MedicationRequestMapperTests to use nested classes for the grouped tests for acute and repeat when two ehrSupplyPrescribe reference one ehrSupplyAuthorise.

Why

Refactoring to group similar tests into nested test classes for readability and to allow more descriptive test names

Type of change

Please delete options that are not relevant.

  • Internal change (non-breaking change with no effect on the functionality affecting end users)

Checklist:

  • I have performed a self-review of my code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@MartinWheelerMT MartinWheelerMT force-pushed the refactor-medication-request-mapper-tests branch from ce439a8 to 5922501 Compare October 9, 2024 09:05
…lassed for the grouped tests for `acute` and `repeat` when two `ehrSupplyPrescribe` reference one `ehrSupplyAuthorise`.
@MartinWheelerMT MartinWheelerMT force-pushed the refactor-medication-request-mapper-tests branch from 5922501 to a84c330 Compare October 9, 2024 09:08
Comment on lines +372 to +373
@DisplayName("WhenTwoEhrSupplyPrescribeReferenceOneRepeatEhrSupplyAuthorise")
class TwoEhrSupplyPrescribeReferenceOneRepeatEhrSupplyAuthorise {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that the display is only 4 characters different to the class name, what was the thinking for using DisplayName?

);
}
assertAll(
() -> assertThat(planMedicationRequests).as("Plans").hasSize(1),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This as is new to me. Like a whole new junit.

.mapResources(ehrExtract, (Patient) new Patient().setId(PATIENT_ID), List.of(), PRACTISE_CODE);
@Nested()
@DisplayName("WhenTwoEhrSupplyPrescribeReferenceOneAcuteEhrSupplyAuthorise")
class TwoEhrSupplyPrescribeReferenceOneAcuteEhrSupplyAuthorise {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar DisplayName thing here, but it's not major.

Comment on lines +377 to +387
@BeforeAll
static void beforeAll() {
ehrExtract = unmarshallEhrExtract(
"ehrExtract_MultipleSupplyPrescribeInFulfilmentOfSingleNonAcuteSupplyAuthorise.xml"
);
}

var earliestOrder = getMedicationRequestById(resources, EARLIEST_ORDER_ID);
@BeforeEach
void beforeEach() {
setupMultipleOrdersToOnePlanStubs(REPEAT_PRESCRIPTION_EXTENSION);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Very minor, but I've never really understood the benefit of beforeAll, unless the setup is actually very slow and there is a performance benefit. Otherwise it just mildly hampers the readability.

@adrianclay adrianclay merged commit 6456f68 into main Oct 11, 2024
1 check passed
@adrianclay adrianclay deleted the refactor-medication-request-mapper-tests branch October 11, 2024 11:51
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.

2 participants