Skip to content

Commit

Permalink
Additional test to ensure all constructors are checked
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasyishak committed Oct 25, 2023
1 parent 7f59e32 commit 922a2d1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkgs/unified_analytics/test/event_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:mirrors';

import 'package:test/test.dart';

import 'package:unified_analytics/src/enums.dart';
Expand Down Expand Up @@ -308,4 +310,20 @@ void main() {
expect(constructedEvent.eventData['surveyId'], 'surveyId');
expect(constructedEvent.eventData.length, 1);
});

test('Confirm all constructors were checked', () {
var constructorCount = 0;
for (var declaration in reflectClass(Event).declarations.keys) {
if (declaration.toString().contains('Event.')) constructorCount++;
}

// Change this integer below if your PR either adds or removes
// an Event constructor
final eventsAccountedForInTests = 17;
expect(eventsAccountedForInTests, constructorCount,
reason: 'If you added or removed an event constructor, '
'ensure you have updated '
'`pkgs/unified_analytics/test/event_test.dart` '
'to reflect the changes made');
});
}

0 comments on commit 922a2d1

Please sign in to comment.