When testing components, the building blocks used to create integrations, your goal should be to test the functions the component provides, independent of any business requirements for a specific integration. This should include things like:
- The actual functions of the component do what they are supposed to do
- Ensuring all configuration fields behave as expected
- Proper error handling is used for handling bad configuration
- Proper error handling is used for handling unexpected data issues
- Components emit messages to the platforms messaging framework properly
Often, the person or team building and testing components is separate from the person or team building and testing integration flows. Even if this is not the case, you should think of building and testing components as a separate, prerequisite to using and testing those components in a flow.
There are two types of testing worth executing to validate continued functionality of components: Unit Testing and Contract Testing.
Unit Testing Components
Generally components from the Open Integration Hub open source community are shipped with built in unit tests. These tests provide a reasonable, automatable test harness to ensure the basic functions of the component are operational.
Since the components are open sourced and generally contributed by the community, there are no guarantees that unit tests exist, nor are there guarantees about test coverage over the code. However, the Blended Edge-managed open source components should meet or exceed a pretty high bar for unit test coverage.
Anyone who contributes new functionality (or modifies existing functionality) to a component is strongly encouraged to include unit tests that validate that functionality. Updates to Blended Edge components will not be accepted without unit tests or a significant exceptional reason.
Unit tests are typically written using Mocha.
Contract Testing Components
Contract testing a component would assert the structure of messages produced and consumed for each component. This does not currently exist in any of the components, but could be executed using Pact.