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

UnitTests in FhirResourceDaoR4ValidateTest are highly dependent #3200

Open
TipzCM opened this issue Nov 29, 2021 · 0 comments
Open

UnitTests in FhirResourceDaoR4ValidateTest are highly dependent #3200

TipzCM opened this issue Nov 29, 2021 · 0 comments

Comments

@TipzCM
Copy link
Collaborator

TipzCM commented Nov 29, 2021

Running all the tests in FhirResourceDaoR4ValidateTest will result in the entire test suite passing.

However, running individual tests will result in those same tests failing.

testValidateWithFragmentCodeSystem_WithDirectBinding for instance, fails when run alone.

Including the following code at the beginning of the tests will cause it to pass, however:

String resource = loadResource("/r4/uscore/patient-resource-badcode.json");
IBaseResource parsedResource = myFhirCtx.newJsonParser().parseResource(resource);
try {
	myPatientDao.validate((Patient) parsedResource, null, resource, null, null, null, mySrd);
} catch (PreconditionFailedException e) {
}

Since this code is only doing validation, it's likely the underlying code is bugged, too. Ie, one does not expect calls to validate to be dependant on previous calls to validate.

Expected Results

  • Tests should not be dependant on each other
  • Calls to validate should not be dependant on previous calls to validate

As an aside, the underlying BaseJpaR4Test should be cleaned up to only have a single BeforeEach and a single AfterEach. Multiples are not advisable as they are run in alphabetical order one after another (combining all of the BeforeEach/AfterEach into one is advisable)

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

No branches or pull requests

1 participant