-
Notifications
You must be signed in to change notification settings - Fork 165
Test Coverage in FDC3
This page documents how test coverage is collected, aggregated, and reported across the FDC3 monorepo.
The FDC3 project uses a multi-layered approach to test coverage, combining different testing frameworks across its various modules. Coverage data from all modules is merged into a single report to provide a unified view of the project's test coverage.
Different modules in the FDC3 monorepo use different testing frameworks. See the FDC3 Project Structure section in the README for the complete list of modules and their testing/coverage approaches.
From the root of the repository:
npm run testThis command executes the test script in all workspace packages that have one defined.
Each package can have its tests run independently:
# For fdc3-standard (Jest)
cd packages/fdc3-standard
npm run test
# For fdc3-agent-proxy (Cucumber)
cd packages/fdc3-agent-proxy
npm run test
# For fdc3-get-agent (Cucumber)
cd packages/fdc3-get-agent
npm run testCoverage is collected using nyc/istanbul for each sub-module. The project uses istanbul-merge to combine coverage data from all tested modules into a single report. The merged coverage data is written to coverage/complete.json.
This is then reported on GitHub PRs like so:
Cucumber is used for behavior-driven development (BDD) testing in the fdc3-agent-proxy and fdc3-get-agent modules.
Feature files define test scenarios in Gherkin syntax:
Example from packages/fdc3-agent-proxy/test/features/broadcast.feature:
Feature: Broadcasting
Background: Desktop Agent API
Given schemas loaded
Given User Channels one, two and three
Given A Desktop Agent in "api"
Given "instrumentContext" is a "fdc3.instrument" context
Scenario: Broadcasting on a named app channel
When I call "{api}" with "getOrCreateChannel" with parameter "channel-name"
And I refer to "{result}" as "channel1"
And I call "{channel1}" with "broadcast" with parameter "{instrumentContext}"
Then messaging will have posts
| payload.channelId | payload.context.type | matches_type |
| channel-name | fdc3.instrument | broadcastRequest |The packages/fdc3-testing module (@finos/fdc3-testing) provides a shared testing infrastructure...
See the fdc3-testing README for full documentation of the testing DSL, including:
- Variable references using
{variable}syntax - Core step definitions for calling methods and assertions
- JSONPath matching for validating complex objects
- Schema validation using the
matches_typecolumn - Usage instructions for adding tests to new packages