ethos_test library
Test utilities for Ethos — matchers and helpers for use in
dart test or flutter_test suites.
Import this in test files only:
// In your test file:
import 'package:ethos/ethos_test.dart';
import 'package:test/test.dart';
void main() {
group('Accessibility', () {
late CoverageReport report;
setUpAll(() async {
report = await EthosTestHelper.analyzeProject('lib/');
});
test('meets WCAG Level A', () {
expect(report, meetsAccessibilityLevel(WcagLevel.a));
});
test('semantic labels above 80%', () {
expect(report, hasRuleCoverage(
'wcag_1_3_1_semantics_label',
greaterThan(80),
));
});
test('no critical failures', () {
expect(report, hasNoCriticalFailures());
});
});
}
Do NOT import this in production code — use package:ethos/ethos.dart
for the main API.
Classes
- CoverageReport
- Report model for accessibility coverage analysis results.
- EthosTestHelper
-
Test utilities for using Ethos inside a
dart testorflutter_testsuite. - Finding
- A single non-compliant or indeterminate element found by a detector.
- RuleCoverage
- Coverage details for a specific rule.
Enums
- FindingSeverity
- WcagLevel
- WCAG compliance levels used in test matchers.
Functions
-
hasNoCriticalFailures(
) → Matcher - Matches a CoverageReport with no rules below their critical threshold.
-
hasNoFindingsFor(
String ruleId) → Matcher -
Matches a CoverageReport with no Findings for the given
ruleId. -
hasRuleCoverage(
String ruleId, Matcher coverageMatcher) → Matcher -
Matches a CoverageReport where the rule identified by
ruleIdhas a coverage percentage that satisfiescoverageMatcher. -
meetsAccessibilityLevel(
WcagLevel level) → Matcher -
Matches a CoverageReport whose CoverageReport.complianceLevel is at
least
level. -
passesRule(
String ruleId) → Matcher -
Matches a CoverageReport where the rule identified by
ruleIdis not critical (i.e. its coverage is at or above the rule's critical threshold).
Exceptions / Errors
- TestFailure
- Thrown by EthosTestHelper.expectNoCriticalFailures when critical failures are detected.