fhir-crucible / testscript-engine

Ruby FHIR TestScript execution engine
Apache License 2.0
5 stars 2 forks source link

Add handling minimum_id #55

Closed jhlee-mitre closed 2 years ago

jhlee-mitre commented 2 years ago

Summary

Add handling minimum_id in Assert

New behavior

If a TestScript contains a minimumId in Assert, the engine examines if the response contains at a minimum fixture specified by minimumId. The definition of "minimum" is

  1. All the elements with their values in the minimum fixture should exist the same in the response. (order doesn't matter)
  2. Elements and values in the minimum fixture and the response should be in the same hierarchies.

Code changes

Added a Hash function: deep_merge() in assertion.rb. This is a function merging two hashes into one recursively. The essential logic of judging whether a minimum fixture included in response or not is:

  1. Convert FHIR resources into Hash
  2. Merge minimum fixture and response into one
  3. If the merged Hash is same as the response, minimum fixture is included in response. If there is any unique element/value on the minimum fixture's end, the merged Hash will contain it (difference). Therefore the merged Hash won't be same as the response.

Testing guidance

Use general_testscript.json

jhlee-mitre commented 2 years ago

The approach looks solid, but some brief changes requested. Also, you should create rspec unit tests for minimumId. You should create an assertions subfolder within the spec directory, and then something like a minimum_id_spec.rb file to test this behavior.

Yes, I will add rspec.

jhlee-mitre commented 2 years ago

The approach looks solid, but some brief changes requested. Also, you should create rspec unit tests for minimumId. You should create an assertions subfolder within the spec directory, and then something like a minimum_id_spec.rb file to test this behavior.

Does this minimum_id rspec part need to be separate from assertions_spec.rb?

ms-k1ngk0ng commented 2 years ago

The approach looks solid, but some brief changes requested. Also, you should create rspec unit tests for minimumId. You should create an assertions subfolder within the spec directory, and then something like a minimum_id_spec.rb file to test this behavior.

Does this minimum_id rspec part need to be separate from assertions_spec.rb?

Not necessarily - but I think, organizationally, it'll be much easier to keep track of our unit tests if we have an assertions subdirectory and then a file within that for each type of assertion.

jhlee-mitre commented 2 years ago

Got it. I will create a separate one. Thanks!

jhlee-mitre commented 2 years ago

Incorporated all suggestions.