Client Suite Unit Tests and Unit Test Patterns #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add unit tests for the client suite and also start to build standard unit test infrastructure for Inferno unit tests.
Unit Testing Shared Artifacts
Created a suite rspec
[shared_context](https://github.com/inferno-framework/subscriptions-test-kit/blob/client-suite-unit-tests/spec/subscriptions_test_kit/suite_spec_context.rb)
that gets included at the top of the unit test to define variables and functions that are expected to be used in most unit tests. Currently, these includesuite
: the suite found in the TestSuite Repositorysuite_id
: the suite idsession_data_repo
: session data repositoryvalidation_url
: url for validator requeststest_session
: session data for this suite's runrun
: function to execute a specific runnablefind_test
: function to find a specific runnable within the suite - used to get the runnable to execute. This is an attempt to make a simple interface for finding the test by always loading the full suite and finding a specific test within it.Questions for reviewers:
Unit Testing Patterns
I created one spec file for a test that includes what I think can be some standard patterns. I included some documentation of them in that class that would probably be moved elsewhere eventually.
Execution with tester-inputs
The test requires tester inputs, specifically an access token and a notification Bundle. The unit test contains a pattern for instantiating the test and executing it.
Wait Tests
This test includes some verification before a wait dialog. The unit test contains a pattern for testing that the wait can be completed as expected.
Questions for reviewers:
Additional Potential Patterns
stub_request(:get, "#{export_url}?_outputFormat=application%2Fndjson").to_return(status: 400)
post(...)
(similar to wait stuff)allow_any_instance_of(test).to(eceive(:suite_options).and_return(ONCCertificationG10TestKit::G10Options::US_CORE_3_REQUIREMENT)
result = repo_create(:result, test_session_id: test_session.id)
andrepo_create(:request, result_id: result.id, name: 'questionnaire_package', request_body: nil, test_session_id: test_session.id, tags: [DaVinciDTRTestKit::QUESTIONNAIRE_PACKAGE_TAG])
Testing Guidance
run rspec using
bundle exec rspec